# Image Optimizer & Converter: WebP, AVIF, JPG (`bigaceboy/image-optimizer-converter`) Actor

Compress images and convert to WebP, AVIF, JPG or PNG in bulk. Resize to max width/height, hit a target file size in KB, strip EXIF/GPS, auto-rotate phone photos. Image URLs or uploads, up to 1,000 per run. $0.002 per image, failures free. API, n8n, Make and MCP ready.

- **URL**: https://apify.com/bigaceboy/image-optimizer-converter.md
- **Developed by:** [Anthony Crawford](https://apify.com/bigaceboy) (community)
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.00 / 1,000 image optimizeds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

**Compress images, resize them and convert to WebP, AVIF, JPG or PNG in bulk.** Image Optimizer & Converter takes image URLs or uploads and returns smaller, web-ready files: shrunk to fit your **max width/height** (never enlarged), optionally squeezed under a **target file size in KB**, with **EXIF and GPS location data removed** and phone photos **rotated upright**. Every result has a direct download link and before/after sizes. **$0.002 per image**, failed images are free. A simple image compression API for websites, shops, n8n/Make/Zapier automations and AI agents via the Apify MCP server.

### What can this image compressor and converter do?

- 🗜️ **Compress images** with modern encoders (libwebp, AVIF, mozjpeg, palette PNG). Typical savings: 60–95% for camera photos (a 14.7 MB photo became ~165 KB WebP in our test).
- 🔄 **Convert image formats**: JPEG, PNG, WebP, AVIF, GIF (first frame) and TIFF → **WebP, AVIF, JPEG, PNG**, or `keep` the original format.
- 📏 **Resize** to fit inside `maxWidth` × `maxHeight`, keeping the aspect ratio. Small images are never upscaled.
- 🎯 **Target file size**: set `targetMaxKB` (e.g. 500) and the Actor finds the highest quality that fits, shrinking slightly if needed. Rows report `targetMet`.
- 🔒 **Privacy**: `stripMetadata` (on by default) removes EXIF, GPS, camera and XMP data; each row says whether the original had GPS.
- 📱 **Auto-rotate** from EXIF orientation, and **flatten transparency** onto a background color when converting to JPEG.
- 📦 **Bulk**: up to 1,000 images per run.
- 🛡️ **Safe downloads**: only public http(s) URLs; private/loopback/link-local/cloud-metadata addresses are blocked, with size and time limits.

### Who is it for?

- **Website owners, shops and bloggers** converting product photos to WebP/AVIF for faster pages and better Core Web Vitals.
- **No-code automations** (n8n, Make, Zapier) that must meet upload limits like "under 500 KB" or "max 2000 px".
- **AI agents** (via Apify MCP or API) that need a smaller or web-friendly copy of an image before uploading, emailing or embedding it.

### How to convert images to WebP in bulk

1. Click **Try for free** (or **Start**) and sign in to Apify.
2. Paste image links into **Image URLs** (or upload files).
3. Choose **Output format** (WebP is the default) and, optionally, **Max width** and **Target max file size**.
4. Leave **Strip metadata** on to remove GPS location.
5. Click **Start**. The **Output** tab lists each file with `outputUrl` and how much space was saved.

### Input example

```json
{
  "imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg"],
  "outputFormat": "webp",
  "maxWidth": 1600,
  "targetMaxKB": 300,
  "stripMetadata": true
}
```

This optimizes 1 image = **$0.002**.

#### All input fields

| Field | Type | Default | Notes |
| --- | --- | --- | --- |
| `imageUrls` | array of strings | – | Public image links, or `kvs://<store>/<key>`. |
| `keyValueStoreImages` | array | – | Uploads or `<storeId>/<key>` references. |
| `outputFormat` | string | `webp` | `webp`, `avif`, `jpeg`, `png`, `keep`. |
| `quality` | integer | per format | Empty = WebP 80, AVIF 55, JPEG 82, PNG lossless. |
| `maxWidth` / `maxHeight` | integer | – | Fit inside, no upscaling. |
| `targetMaxKB` | integer | – | Max output size per file. |
| `stripMetadata` | boolean | `true` | Removes EXIF/GPS/XMP, converts to sRGB. |
| `autoRotate` | boolean | `true` | |
| `backgroundColor` | hex | `#FFFFFF` | Behind transparency for JPEG. |
| `minQuality` | integer | `35` | Floor for the target-size search. |
| `effort` | integer | `4` | 0–9 encoder effort (WebP/AVIF). |
| `maxInputSizeMb` | integer | `25` | Max 50. |
| `downloadTimeoutSecs` | integer | `30` | |

### Output example

```json
{
  "source": "https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg",
  "format": "avif",
  "width": 1600,
  "height": 719,
  "originalFormat": "jpeg",
  "originalBytes": 14679474,
  "outputBytes": 97000,
  "savedPercent": 99.3,
  "quality": 55,
  "targetMet": true,
  "metadataStripped": true,
  "hadGps": false,
  "outputUrl": "https://api.apify.com/v2/key-value-stores/<id>/records/001-Fronalpstock_big.avif",
  "status": "ok",
  "errorCode": null,
  "charged": true
}
```

Error codes: `INVALID_URL`, `BLOCKED_URL`, `DNS_FAILED`, `HTTP_ERROR`, `DOWNLOAD_FAILED`, `DOWNLOAD_TIMEOUT`, `TOO_LARGE`, `TOO_MANY_PIXELS`, `UNSUPPORTED_FORMAT`, `NOT_FOUND`, `PROCESSING_FAILED`. Error rows are never charged.

### How much does image compression cost?

| What you do | Images | Price |
| --- | --- | --- |
| 1 photo → WebP | 1 | $0.002 |
| 500 product photos → WebP, max 1600 px | 500 | $1.00 |
| 1,000 images | 1,000 | $2.00 |

| Event | Price | When |
| --- | --- | --- |
| `image-optimized` | **$0.002** | One optimized file was saved and is downloadable. |
| `apify-actor-start` | Apify's tiny standard start fee | Once per run. |

Failures are free, and runs stop cleanly at your maximum charge per run. Apify's free plan includes monthly platform credit, enough to try it many times.

### Use with AI agents (Apify MCP server)

Load just this tool from the hosted [Apify MCP server](https://mcp.apify.com):

```
https://mcp.apify.com?tools=bigaceboy/image-optimizer-converter
```

```json
{
  "mcpServers": {
    "image-optimizer": { "url": "https://mcp.apify.com?tools=bigaceboy/image-optimizer-converter" }
  }
}
```

Then ask: *"Convert these product photos to WebP under 300 KB, max 1600 px wide, and remove the GPS data."* The agent sends `imageUrls`, `outputFormat`, `maxWidth`, `targetMaxKB` and reads `outputUrl`.

### Use with n8n, Make and Zapier

- **n8n**: **Apify** node → *Actors* → **Run an Actor and Get Dataset** → Actor `bigaceboy/image-optimizer-converter`, input `{ "imageUrls": ["{{ $json.imageUrl }}"], "outputFormat": "webp", "maxWidth": 1600 }`, then upload `outputUrl` to WordPress, Shopify, S3 or Google Drive.
- **Make**: Apify → **Run an Actor** (wait for finish) → **Get Dataset Items** → map `outputUrl`.
- **Zapier**: Apify → **Run Actor** (synchronous), then use `outputUrl`.

### Use with the API (curl, JavaScript, Python)

```bash
curl -X POST "https://api.apify.com/v2/acts/bigaceboy~image-optimizer-converter/run-sync-get-dataset-items" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"imageUrls":["https://upload.wikimedia.org/wikipedia/commons/3/3f/Fronalpstock_big.jpg"],"outputFormat":"webp","maxWidth":1600}'
```

```js
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: process.env.APIFY_TOKEN });
const run = await client.actor('bigaceboy/image-optimizer-converter').call({ imageUrls: ['https://example.com/photo.jpg'], outputFormat: 'webp', maxWidth: 1600 });
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((i) => [i.outputUrl, i.savedPercent]));
```

```python
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("bigaceboy/image-optimizer-converter").call(run_input={"imageUrls": ["https://example.com/photo.jpg"], "outputFormat": "webp", "maxWidth": 1600})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["outputUrl"], item.get("savedPercent"))
```

### FAQ

#### WebP or AVIF: which should I choose?

**WebP** works in every modern browser and is fast to encode. **AVIF** is usually 20–30% smaller at the same visual quality but slower to encode. If unsure, use WebP.

#### How do I compress an image to under 500 KB (or 100 KB)?

Set `targetMaxKB: 500`. The Actor lowers quality step by step down to `minQuality`, then shrinks dimensions slightly if still needed. Check `targetMet` in the output.

#### Does it remove GPS location from photos?

Yes, by default (`stripMetadata: true`). Each row reports `hadGps` for the original.

#### Will it make my images bigger?

It never upscales. If an original is already very well compressed, the new file can be slightly larger; the row shows both sizes so you can keep the original.

#### Does it support HEIC or SVG?

Not right now. Convert HEIC on the phone first; SVGs are vectors and don't need this.

#### Can I keep the original format and only shrink it?

Yes, set `outputFormat: "keep"` (GIF becomes PNG, TIFF becomes JPEG).

### Other tools by this developer

| Tool | What it does | Price |
| --- | --- | --- |
| [Social Image Resizer (No Crop)](https://apify.com/bigaceboy/social-image-letterboxer) | Fit photos into Instagram/Pinterest/Story sizes without cropping | $0.005 / image |
| [Website Screenshot to Social Image](https://apify.com/bigaceboy/website-screenshot-to-social) | Screenshot any URL into Instagram, Pinterest or OG 1200×630 images | $0.004 / image |
| [Markdown & HTML to PDF Converter](https://apify.com/bigaceboy/markdown-html-to-pdf) | Turn Markdown, HTML or a URL into a clean PDF | $0.004 / PDF |

### Limits

- Up to 1,000 images per run, 50 MB per file, 100 MP input, 40 MP output (set `maxWidth` for huge panoramas). WebP is limited to 16,383 px per side.
- Animated GIF/WebP: first frame only. SVG and HEIC (iPhone HEVC) inputs are not supported.
- Questions or feature requests: use the **Issues** tab.

# Actor input Schema

## `imageUrls` (type: `array`):

Direct, public links to image files (JPG, PNG, WebP, AVIF, GIF first frame, TIFF). Private, localhost and cloud-metadata addresses are blocked. You can also pass Apify key-value store records as kvs://<storeIdOrName>/<key>.

## `keyValueStoreImages` (type: `array`):

Optional. Upload files here, or reference images in an Apify key-value store as "<storeIdOrName>/<key>" (or "<key>" for this run's default store).

## `outputFormat` (type: `string`):

webp = small and supported everywhere modern (default). avif = smallest, newer. jpeg = universal (transparency is flattened onto the background color). png = lossless (or palette-compressed when quality < 100 or a target size is set). keep = same format as the input (GIF → PNG, TIFF → JPEG).

## `quality` (type: `integer`):

1–100. Leave empty for smart defaults: WebP 80, AVIF 55, JPEG 82, PNG lossless.

## `maxWidth` (type: `integer`):

Shrink to fit inside this width, keeping the aspect ratio. Smaller images are never enlarged. Empty = keep size.

## `maxHeight` (type: `integer`):

Shrink to fit inside this height. Empty = keep size.

## `targetMaxKB` (type: `integer`):

Optional, e.g. 500 to keep every file under 500 KB. Lowers quality step by step (down to Min quality) until each file fits; if still too big, shrinks the dimensions a little. Rows show targetMet.

## `stripMetadata` (type: `boolean`):

Removes EXIF, GPS location, camera info and XMP, and converts colors to sRGB. Recommended for web and privacy.

## `autoRotate` (type: `boolean`):

Rotate phone photos upright using their EXIF orientation.

## `backgroundColor` (type: `string`):

Hex color placed behind transparent areas when converting to JPEG, e.g. #FFFFFF.

## `minQuality` (type: `integer`):

Lowest quality the target-size search may use.

## `effort` (type: `integer`):

0–9 for WebP/AVIF. Higher = slightly smaller files but slower.

## `maxInputSizeMb` (type: `integer`):

Bigger files are skipped with TOO_LARGE (not charged).

## `downloadTimeoutSecs` (type: `integer`):

Give up on an image URL after this long (not charged).

## Actor input object example

```json
{
  "imageUrls": [
    "https://images.unsplash.com/photo-1512389142860-9c449e58a543?w=1600"
  ],
  "outputFormat": "webp",
  "quality": 80,
  "maxWidth": 1600,
  "maxHeight": 1600,
  "targetMaxKB": 300,
  "stripMetadata": true,
  "autoRotate": true,
  "backgroundColor": "#FFFFFF",
  "minQuality": 35,
  "effort": 4,
  "maxInputSizeMb": 25,
  "downloadTimeoutSecs": 30
}
```

# Actor output Schema

## `results` (type: `string`):

Dataset rows: source, format, width, height, originalBytes, outputBytes, savedPercent, outputUrl, status, errorCode, charged.

## `files` (type: `string`):

Keys of the optimized images saved in the default key-value store.

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "imageUrls": [
        "https://images.unsplash.com/photo-1512389142860-9c449e58a543?w=1600"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("bigaceboy/image-optimizer-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "imageUrls": ["https://images.unsplash.com/photo-1512389142860-9c449e58a543?w=1600"] }

# Run the Actor and wait for it to finish
run = client.actor("bigaceboy/image-optimizer-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "imageUrls": [
    "https://images.unsplash.com/photo-1512389142860-9c449e58a543?w=1600"
  ]
}' |
apify call bigaceboy/image-optimizer-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,bigaceboy/image-optimizer-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/NruvPhsLsYdIMha95/builds/0KOb3V2b6bJyQs9YH/openapi.json
