# Bulk Image Converter & Compressor — WebP, AVIF, JPEG, PNG (`docflow-tools/bulk-image-converter-compressor`) Actor

Convert, compress and resize images in bulk: WebP, AVIF, JPEG or PNG from JPEG, PNG, WebP, AVIF, HEIC (iPhone), GIF, BMP, TIFF. Target file size in KB, EXIF/GPS stripped, auto-rotate. Feed URLs or any Apify dataset. Failed images are free.

- **URL**: https://apify.com/docflow-tools/bulk-image-converter-compressor.md
- **Developed by:** [DocFlow Tools](https://apify.com/docflow-tools) (community)
- **Categories:** Developer tools, Automation, E-commerce
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.60 / 1,000 image converteds

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.
Since this Actor supports Apify Store discounts, the price gets lower the higher subscription plan you have.

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

## Bulk Image Converter & Compressor — WebP, AVIF, JPEG, PNG

Convert, compress and resize images in bulk. Give the Actor image links, or pick an Apify dataset (for example the
output of a scraper) and it finds the image URLs in each row. Each image is converted to **WebP, AVIF, JPEG or PNG**,
optionally resized to a maximum width or height, optionally squeezed under a **target file size in KB**, auto-rotated
according to the camera orientation and saved **without EXIF or GPS metadata**. You pay a flat price per converted
image; failed images are free.

### What you get

One dataset item per image, the converted file in the run's key-value store, and run totals in `SUMMARY`.

| Field | Description |
|---|---|
| `sourceUrl` | The original image URL |
| `outputFormat` | `webp`, `avif`, `jpeg` or `png` |
| `outputUrl` | Direct link to the converted file |
| `key` | Key of the file in the run's key-value store, e.g. `00001-photo-3fa2b1.webp` |
| `contentType` | MIME type of the output, e.g. `image/webp` |
| `inputFormat` | Detected input format, e.g. `jpeg`, `png`, `heif` |
| `width`, `height` | Output dimensions in pixels |
| `quality` | Quality used (`null` for PNG); lower than requested if a target size forced it |
| `inputBytes`, `outputBytes` | File size before and after |
| `savedPercent` | Size reduction in %, negative if the output is bigger |
| `sizeTargetSearch` | `true` if the Actor had to search for a quality or size that fits *Target max size* |
| `error` | Only on failed images (then only `sourceUrl`, `outputFormat` and `error` are present) |

`SUMMARY`: `images`, `converted`, `failed`, `inputBytes`, `outputBytes`, `savedPercent`, `stoppedAtSpendingLimit`.

**Input formats**: JPEG, PNG, WebP, AVIF, HEIC/HEIF (iPhone photos), GIF (first frame), BMP, TIFF.
**Output formats**: WebP, AVIF, JPEG, PNG.

### Use cases

- **Faster websites**: convert product or blog images to WebP or AVIF at a maximum width for lighter pages.
- **Upload limits**: fit photos under a size limit (for example 200 KB for a marketplace or a form).
- **Clean scraper output**: chain it after a scraper and convert every image URL found in its dataset.
- **iPhone photos**: turn HEIC files into JPEG or WebP that every browser and tool opens.
- **Privacy before publishing**: strip EXIF and GPS location from photos while keeping the right orientation.

### How to use

1. Paste image links into **Image URLs**, and/or pick one or more **Apify datasets**.
2. For datasets, optionally set **Image URL field** (a field holding a URL or a list of URLs). Leave it empty to
   detect image fields automatically.
3. Choose the **Output format** and **Quality** (default 80).
4. Optional: **Max width** / **Max height**, **Target max size (KB)**, **Lossless**.
5. Click **Start**. Each item in the *Output* tab links to its converted file.

Input example:

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg",
    "https://example.com/photos/IMG_0042.HEIC"
  ],
  "datasetIds": ["YOUR_DATASET_ID"],
  "imageUrlField": "imageUrl",
  "outputFormat": "webp",
  "quality": 80,
  "maxWidth": 1600,
  "maxSizeKB": 200,
  "lossless": false
}
```

### Output example

Real values for the prefilled example image (WebP, quality 80); the link is shortened.

```json
{
  "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg",
  "outputFormat": "webp",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/00001-Example-93c8f8.webp",
  "key": "00001-Example-93c8f8.webp",
  "contentType": "image/webp",
  "inputFormat": "jpeg",
  "width": 172,
  "height": 178,
  "quality": 80,
  "inputBytes": 9022,
  "outputBytes": 2922,
  "sizeTargetSearch": false,
  "savedPercent": 67.6
}
```

A failed image (not charged):

```json
{ "sourceUrl": "https://example.com/missing.jpg", "outputFormat": "webp",
  "error": "Client error '404 Not Found' for url 'https://example.com/missing.jpg'" }
```

### How the target size works

When you set **Target max size (KB)** (not available for PNG):

1. The image is resized to your max width/height (if set) and encoded at your **Quality**.
2. If it already fits, that's the result: no search, no extra charge.
3. If not, the Actor searches for the **highest quality between 20 and your quality minus 1** that fits.
4. If even quality 20 doesn't fit, it shrinks the dimensions by 15% and searches again, until it fits or the shorter
   side reaches 32 px. In that last case you get the smallest attempt, which may still be above the target.

### Pricing

> **Prices by Apify discount tier:** the prices below are for the Bronze tier. **Free plan: 50 % off.** Silver: 10 % off. Gold and higher: 20 % off. Apify applies the right price automatically.

Pay per event, in USD:

| Event | Price | When it is charged |
|---|---|---|
| Actor start | $0.00005 | Charged by Apify when a run starts, per GB of run memory (default memory: 1 GB) |
| `image-converted` | $0.002 | Per image converted and saved, any size or format |
| `size-target-fit` | $0.002 | Extra, only for images that did **not** fit the target size at your quality and needed the search above |

**Not charged**: images that fail to download, are too large, can't be decoded, or come from blocked addresses.

Worked examples (1 GB run, start = $0.00005):

- 500 product photos to WebP, no target size: 500 × $0.002 = $1.00, plus start = **$1.00005**.
- 500 photos with a 200 KB target, of which 300 needed the search: 500 × $0.002 + 300 × $0.002 = $1.60, plus start
  \= **$1.60005**.
- 2,000 image URLs from a scraper dataset, 40 of them broken links: 1,960 × $0.002 = $3.92, plus start =
  **$3.92005**.

Set Apify's *maximum cost per run* to cap the spend: nothing is charged beyond the limit, and `SUMMARY` shows
`"stoppedAtSpendingLimit": true`.

### Use it from code, AI agents and integrations

Apify API, run and get the results in one call (waits up to 5 minutes; use the regular run endpoint for big batches):

```bash
curl -X POST "https://api.apify.com/v2/acts/docflow-tools~bulk-image-converter-compressor/run-sync-get-dataset-items?token=YOUR_APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"], "outputFormat": "avif", "maxWidth": 1200}'
```

Python with `apify-client`:

```python
from apify_client import ApifyClient

client = ApifyClient("YOUR_APIFY_TOKEN")
run = client.actor("docflow-tools/bulk-image-converter-compressor").call(run_input={
    "datasetIds": ["SCRAPER_DATASET_ID"],
    "outputFormat": "jpeg",
    "quality": 85,
    "maxWidth": 1920,
    "maxSizeKB": 300,
})
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(item["sourceUrl"], item.get("outputUrl"), item.get("savedPercent"), item.get("error"))
```

- **AI agents**: the Actor can be found and called by AI agents through the Apify MCP server at https://mcp.apify.com.
- **No-code**: use it from Make, Zapier or n8n through Apify's integrations, or run it automatically after a scraper
  with an Apify webhook.

### Limits and notes

- **Up to 20,000 images per run** and **50 MB per image**. Repeated URLs are processed once.
- Only `http` and `https` links; links to private, loopback, link-local or reserved IP addresses are blocked.
  Download timeout 60 seconds, redirects followed.
- Very large images are rejected by the decompression-bomb guard (the image library's limit is set to 120 megapixels
  and it refuses images above twice that).
- **Resizing** keeps the aspect ratio and never enlarges an image.
- **Metadata**: EXIF (including GPS) is not written to the output. Photos are rotated according to their EXIF
  orientation first, so they don't come out sideways.
- **Transparency**: kept in WebP, AVIF and PNG; for JPEG, transparent areas are filled with white.
- **Animated GIF/WebP**: only the first frame is converted.
- **Lossless**: WebP uses lossless mode; AVIF is encoded at quality 100. PNG is always lossless and ignores *Quality*
  and *Target max size*.
- **Quality** accepts 20-100. AVIF is encoded with a fast speed setting (8).
- **Auto-detection in datasets** (when *Image URL field* is empty): any `http(s)` value, or list of values, whose path
  ends in a common image extension, or that sits in a field whose name contains `image` or `photo`.
- Up to 8 downloads run at once; conversions run one per 512 MB of memory (2 at a time at 1 GB).
- Files stay in the run's key-value store for as long as your Apify plan keeps run storage.

### FAQ

**WebP or AVIF?**
AVIF usually gives smaller files at the same visual quality but takes longer to encode; WebP is faster and supported
almost everywhere. Both keep transparency.

**Why was `size-target-fit` charged for some images and not others?**
It's charged only when the image didn't fit your target at your chosen quality, so the Actor had to try several
encodes to find one that fits.

**Can I convert HEIC photos from an iPhone?**
Yes. HEIC/HEIF is read and can be saved as JPEG, WebP, AVIF or PNG.

**Is the GPS location of my photos removed?**
Yes. EXIF metadata, including GPS, is not copied to the converted file.

**Can it upscale small images?**
No. Max width and height only shrink images.

**Can I use the output of another Actor?**
Yes. Pick its dataset in *Apify datasets*; name the field with *Image URL field* if automatic detection misses it.

### Related tools

- [Document to Markdown for RAG](https://apify.com/docflow-tools/document-to-markdown-rag) — PDF, DOCX, XLSX, PPTX and HTML to clean Markdown with RAG chunks.
- [Feed Reader — only new items](https://apify.com/docflow-tools/feed-reader-only-new) — RSS, Atom and JSON Feed, returning only items you haven't seen.
- [PageSpeed Bulk Regression Monitor](https://apify.com/docflow-tools/pagespeed-bulk-regression-monitor) — PageSpeed Insights and Core Web Vitals for many URLs, flags regressions.
- [Image OCR](https://apify.com/docflow-tools/image-ocr-own-engine) — extract text from images with an own OCR engine.
- [Audio & Video Transcriber](https://apify.com/docflow-tools/audio-transcriber-whisper-local) — Whisper transcripts, SRT and VTT, billed per minute.
- [Merge, Deduplicate & Convert Datasets](https://apify.com/docflow-tools/merge-dedupe-transform-data) — merge datasets and CSV/JSON/Excel files, remove duplicates, export.
- [Website Screenshot & Visual Change Monitor](https://apify.com/docflow-tools/website-screenshot-monitor) — bulk screenshots and visual change detection.
- [Sitemap URL Extractor](https://apify.com/docflow-tools/sitemap-url-extractor-reliable) — every URL of a website from its sitemaps.
- [SEO Audit Crawler](https://apify.com/docflow-tools/seo-audit-crawler-cheap) — on-page SEO score and issues per page.
- [Website to Markdown & llms.txt](https://apify.com/docflow-tools/website-to-markdown-llms-txt) — websites to clean Markdown and llms.txt for LLMs.

# Actor input Schema

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

Links to images (http or https, up to 50 MB each, up to 20,000 per run).

## `datasetIds` (type: `array`):

Optional: datasets from other Actors (e.g. a scraper). Image URLs are taken from each row. Read-only access to the datasets you pick.

## `imageUrlField` (type: `string`):

Field that holds the image URL (or a list of URLs). Empty = detect fields that look like images.

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

Format of the converted images.

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

20-100 for WebP, AVIF and JPEG. 80 is a good balance. Ignored for PNG.

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

Shrink to fit this width, keeping proportions. Images are never enlarged.

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

Shrink to fit this height, keeping proportions. Images are never enlarged.

## `maxSizeKB` (type: `integer`):

Find the best quality that fits this size; if needed, also reduce dimensions. Not for PNG.

## `lossless` (type: `boolean`):

Lossless WebP/AVIF (bigger files, exact pixels).

## Actor input object example

```json
{
  "imageUrls": [
    "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
  ],
  "outputFormat": "webp",
  "quality": 80,
  "lossless": false
}
```

# Actor output Schema

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

No description

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

No description

## `summary` (type: `string`):

No description

# 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://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("docflow-tools/bulk-image-converter-compressor").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://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"] }

# Run the Actor and wait for it to finish
run = client.actor("docflow-tools/bulk-image-converter-compressor").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://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg"
  ]
}' |
apify call docflow-tools/bulk-image-converter-compressor --silent --output-dataset

```

## MCP server setup

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

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/rCoFkJrj79osIIV7c/builds/mi3dda6g3MBGWEraI/openapi.json
