# Batch Image Converter & Resizer: WebP, AVIF, PNG & JPEG (`data-done-right/batch-image-converter`) Actor

Convert and resize images in bulk: image URLs in, WebP, AVIF, PNG or JPEG files out with signed download links. Resize by width, height, fit or percent, set quality, strip metadata, hit a max file size. Direct image files only; no HEIC, SVG or web pages.

- **URL**: https://apify.com/data-done-right/batch-image-converter.md
- **Developed by:** [Data Done Right](https://apify.com/data-done-right) (community)
- **Categories:** Developer tools, Automation, Other
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.36 / 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

## Batch Image Converter & Resizer: WebP, AVIF, PNG & JPEG

Use this **batch image converter** to **convert images to WebP, AVIF, PNG or JPEG in bulk** from a list of image URLs, and to resize them on the way. Paste direct image links, pick an output format, and get one converted file per image with a signed download link, the size before and after, and a clear status. It is also a **bulk image resizer**: scale by width, height, fit mode or percent, set the quality, strip EXIF, or ask for a maximum file size.

**What it does NOT do (read this first)**

- It takes **direct links to image files**, not web pages. A page URL is reported as failed; it does not find images on pages (use "Download Images from URLs: Bulk Image & File Downloader" for that).
- **No HEIC/HEIF, SVG, PDF or RAW input.** Readable inputs: JPEG, PNG, WebP, AVIF, GIF, BMP, TIFF. Output is only WebP, AVIF, PNG or JPEG.
- It honours the host's **robots.txt** and does not log in, use proxies or work around hotlink protection. A 401, 403 or 429 from the host is reported as failed, and a URL that robots.txt disallows is skipped.
- Images above 64 megapixels and files above your source size limit (25 MB by default, 100 MB at most) are refused.
- Resizing is plain resampling: it can enlarge an image but it does not add detail. No AI upscaling, no cropping by subject, no watermarks.

### What you get

- One dataset row per URL: signed download link, output format, bytes before and after, `savedPercent`, pixel size before and after, quality used, `status` and a plain-language `note`.
- The converted files in the run's key-value store (kept as long as the run's storage is kept).
- A `SUMMARY` record with totals, and a `FAILED` record that lists every URL that failed and why.

### What can this image converter do

- **Convert** JPEG, PNG, WebP, AVIF, GIF, BMP and TIFF sources to **WebP, AVIF, PNG or JPEG**.
- **Resize** with `width` and/or `height` (fit `inside` keeps the ratio and never enlarges, `cover` crops to the exact size, `contain` pads to the exact size) or with **`resizePercent`** (50 for half, 200 for double).
- **Quality control**: lossy quality 1-100 for WebP, AVIF and JPEG, or `lossless` for WebP and AVIF. PNG is always lossless.
- **Target file size**: set `targetSizeKb` and the Actor lowers the quality (or the PNG palette) until the file fits. If quality alone cannot do it, turn on `shrinkToTarget` to also reduce the pixel size. Each row says whether the target was reached (`targetMet`).
- **Strip metadata** (on by default): removes EXIF, including GPS, after the orientation has been applied to the pixels, so photos are not turned sideways.
- **Transparency**: kept for WebP, AVIF and PNG; for JPEG it is replaced by your `backgroundColor` (white by default).
- **Animated GIF/WebP to animated WebP** keeps every frame. Other formats keep the first frame and say so in `note`.
- **Safe with bad input**: one bad URL never stops the run. Private, loopback and cloud-metadata addresses are refused.

### How to convert images to WebP in bulk

1. Paste the image links in **Image URLs**, one per line.
2. Leave **Output format** on `webp` (or choose `avif`, `png`, `jpeg`).
3. Optionally set a **Width** (for example 1200) and a **Quality** (75-85 is a good start).
4. Run it. Open the dataset, or download the CSV or JSON. Each `url` is a signed link that works without an API token.

### How to resize images in bulk

Set `width` and/or `height`. With `fit: "inside"` every image is scaled down to fit the box and keeps its shape; smaller images stay as they are unless `allowUpscale` is on. For thumbnails of exactly the same size use `fit: "cover"` (crops from the center) or `"contain"` (adds the background color), with both `width` and `height` set. To scale everything by the same factor use `resizePercent`.

### How to convert PNG to JPEG (or JPEG to PNG) in bulk

Set `outputFormat` to `jpeg` or `png`. Transparent areas of a PNG become your `backgroundColor` in a JPEG. JPEG to PNG is lossless from the decoded pixels; the file is usually much larger.

### How to get images under a maximum file size

Set `targetSizeKb` (for example 200). For WebP, AVIF and JPEG the highest quality that fits is found by bisection, starting from `quality`. PNG is reduced to a smaller color palette in steps (256 down to 16 colors) unless `lossless` is on. If it still does not fit, the row says `targetMet: false`; turn on `shrinkToTarget` to also shrink the pixel size (never below 16 px a side).

### Input example

```json
{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"
  ],
  "outputFormat": "webp",
  "quality": 80,
  "width": 600,
  "stripMetadata": true
}
```

More examples:

- `{"outputFormat": "jpeg", "quality": 85, "backgroundColor": "#ffffff"}` : PNG to JPEG with a white background.
- `{"outputFormat": "avif", "width": 320, "height": 320, "targetSizeKb": 10}` : AVIF thumbnails under 10 KB.
- `{"outputFormat": "png", "resizePercent": 50}` : half-size lossless PNG.
- `{"outputFormat": "webp", "width": 400, "height": 400, "fit": "cover"}` : 400 x 400 square crops.

### Input

| Field | Default | What it does |
|---|---|---|
| `urls` (required) | two sample images | Direct image links, one per line |
| `outputFormat` | `webp` | `webp`, `avif`, `png` or `jpeg` |
| `quality` | 80 | 1-100 for WebP, AVIF, JPEG (highest quality tried when a size target is set) |
| `lossless` | off | Lossless WebP/AVIF (ignored for JPEG; PNG is always lossless) |
| `stripMetadata` | on | Remove EXIF/GPS and the color profile |
| `backgroundColor` | `#ffffff` | Replaces transparency in JPEG, pads `contain` |
| `width`, `height` | 0 (off) | Box or exact size in px |
| `fit` | `inside` | `inside`, `cover` (needs both sizes), `contain` (needs both sizes) |
| `resizePercent` | 0 (off) | 1-400; replaces width, height and fit |
| `allowUpscale` | off | Let width/height enlarge small images |
| `targetSizeKb` | 0 (off) | Largest allowed file size in KB (1 KB = 1000 bytes) |
| `shrinkToTarget` | off | Also reduce pixel size to hit the target |
| `maxImages` | 100 | Most images per run (up to 5,000); extra URLs are skipped, not charged |
| `maxSourceSizeMb` | 25 | Skip larger source files (up to 100) |
| `concurrency` | 4 | Images processed in parallel (1-16) |

### Output

One dataset row per URL. This row comes from a real local run of the example above (the link shown is the form it takes on the Apify platform, where it also carries a signature):

```json
{
  "index": 1,
  "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
  "fileName": "PNG_transparency_demonstration_1.webp",
  "url": "https://api.apify.com/v2/key-value-stores/<storeId>/records/PNG_transparency_demonstration_1-1-c2d7093b4cc8.webp?signature=...",
  "format": "webp",
  "originalFormat": "png",
  "originalBytes": 224566,
  "outputBytes": 46368,
  "savedPercent": 79.4,
  "widthBefore": 800,
  "heightBefore": 600,
  "widthAfter": 600,
  "heightAfter": 450,
  "quality": 80,
  "targetMet": null,
  "status": "converted",
  "error": null,
  "note": "converted png to webp; resized 800x600 to 600x450"
}
```

- `status`: `converted` (delivered, charged), `skipped` (duplicate URL, `maxImages`, robots.txt, spending limit, SVG, address not allowed; not charged) or `failed` (download error, not an image, too many pixels; not charged). `error` says why.
- `savedPercent` is negative when the output is larger than the source (for example a JPEG photo converted to PNG). You asked for that format, so it is still delivered and charged.
- `targetMet` is `null` when no size target was set, otherwise `true` or `false`.

### How much does it cost to convert images

Pay per event: **$0.0017 per converted image** (event `image-converted`, $1.70 per 1,000 images), plus the normal Apify platform usage of the run, which is small for typical images. Skipped and failed URLs are free, and there is no start fee.

- 1,000 images: $1.70
- 10,000 images: $17.00
- 100,000 images: $170.00 (run it in batches of up to 5,000 images per run)

Set a maximum spending limit on the run: it stops cleanly when reached and the rest are reported as skipped.

### Use cases

- Move a website or shop to WebP or AVIF and cut page weight.
- Make thumbnails of one exact size for a catalogue, app or marketplace.
- Convert PNG screenshots to JPEG for tools that reject transparency or large files.
- Get every image under an upload limit (CMS, email, marketplace) with a size target.
- Add a conversion step to a pipeline: another Actor or an AI agent passes image URLs and reads the signed links from the dataset.

### FAQ

**Does it convert HEIC (iPhone photos)?**
No. Use the "HEIC to JPG Converter: Convert HEIC/HEIF to JPG & PNG" Actor first, or send JPEG, PNG, WebP, AVIF, GIF, BMP or TIFF.

**Can it take a web page and find the images?**
No. Only direct links to image files. A page returns `failed` with a message that it is a web page.

**Will it make my images bigger?**
Not by pixel size unless you ask: `inside` and `cover` never enlarge, and only `allowUpscale` or a `resizePercent` above 100 does. File size can grow, for example when you convert a JPEG photo to PNG; `savedPercent` then shows a negative number.

**What happens to transparency?**
It is kept for WebP, AVIF and PNG. JPEG cannot store it, so the transparent areas are filled with `backgroundColor`.

**What happens to a URL that robots.txt disallows?**
It is skipped with the reason and not charged. If a host's robots.txt cannot be read because of a server error, its images are skipped too rather than guessed.

**Is AVIF slow?**
AVIF encoding is slower than WebP or JPEG, and a size target means several encodes per image, so very large images with `targetSizeKb` take longer. Typical web-size images take well under a second each in our local tests.

### Use with the Apify API, MCP, n8n and Make

Python:

```python
from apify_client import ApifyClient

client = ApifyClient("<APIFY_TOKEN>")
run = client.actor("<username>/batch-image-converter").call(run_input={
    "urls": ["https://example.com/photo.jpg"],
    "outputFormat": "webp",
    "width": 1200,
})
for row in client.dataset(run["defaultDatasetId"]).iterate_items():
    print(row["status"], row["url"], row["savedPercent"])
```

JavaScript:

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

const client = new ApifyClient({ token: '<APIFY_TOKEN>' });
const run = await client.actor('<username>/batch-image-converter').call({
  urls: ['https://example.com/photo.jpg'],
  outputFormat: 'webp',
  width: 1200,
});
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items.map((r) => [r.status, r.url]));
```

The same input works from the Apify MCP server (an AI agent calls the Actor with a list of image URLs), from n8n and from Make through their Apify modules.

### Related tools

- **Download Images from URLs: Bulk Image & File Downloader** : collect the images from pages first, then convert them here.
- **Image Compressor & Resizer: Compress Images in Bulk** : shrink images and keep the original format, charged only when the file got smaller.
- **Background Remover for Images (rembg, CPU)** : cut out the subject and save a transparent PNG or WebP.
- **HEIC to JPG Converter: Convert HEIC/HEIF to JPG & PNG** : turn iPhone HEIC photos into JPG or PNG first.

# Actor input Schema

## `urls` (type: `array`):

Direct links to the image files to convert, one per line. JPEG, PNG, WebP, AVIF, GIF, BMP and TIFF are read. Example: https://example.com/photo.jpg. Web pages, SVG and HEIC are not supported. Use only images you have the right to process.

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

Format of every output file. Example: webp. WebP and AVIF are usually the smallest; PNG is lossless; JPEG has no transparency (see Background color).

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

Lossy quality for WebP, AVIF and JPEG; ignored for PNG. 75-85 looks near-identical for most photos. With a size target this is the highest quality tried. Example: 80.

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

Write WebP and AVIF lossless (bigger files, no pixel loss). PNG is always lossless; JPEG is always lossy and ignores this.

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

Remove EXIF (camera, GPS location), XMP and other metadata and the embedded color profile. The orientation is always applied to the pixels first, so photos are never rotated wrongly. Turn off to keep EXIF and the color profile.

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

Replaces transparency when the output is JPEG, and pads the image in fit mode contain. Hex color. Example: #ffffff.

## `width` (type: `integer`):

Target or maximum width in pixels. 0 means not set. With fit mode inside the image is scaled down to fit and never enlarged (unless Allow upscaling). Example: 800.

## `height` (type: `integer`):

Target or maximum height in pixels. 0 means not set. Set only one of width and height to keep the aspect ratio. Example: 600.

## `fit` (type: `string`):

How width and height are applied. inside keeps the ratio and stays within the box. cover and contain need both width and height and give every image exactly that size (cover crops from the center). Example: inside.

## `resizePercent` (type: `integer`):

Scale both sides by this percent, for example 50 for half size or 200 for double. 0 means not set. When set it replaces width, height and fit. Example: 50.

## `allowUpscale` (type: `boolean`):

Let width and height enlarge images that are smaller than the box. Off by default. Resize by percent above 100 always enlarges (plain resampling, no AI).

## `targetSizeKb` (type: `integer`):

Optional. Lower the quality (WebP, AVIF, JPEG) or the number of colors (PNG) until each file is at most this many kilobytes (1 KB = 1000 bytes). 0 means no target. Each row reports targetMet. Example: 200.

## `shrinkToTarget` (type: `boolean`):

When quality alone cannot reach the target size, also reduce the pixel dimensions step by step (never below 16 px). Off by default, so the image size only changes when you ask.

## `maxImages` (type: `integer`):

Most images converted in this run. URLs beyond this are skipped and not charged. Example: 100.

## `maxSourceSizeMb` (type: `integer`):

Source images larger than this are skipped before they are fully downloaded. Images above 64 megapixels are always refused (memory safety).

## `concurrency` (type: `integer`):

How many images are processed at the same time. Default 4.

## Actor input object example

```json
{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"
  ],
  "outputFormat": "webp",
  "quality": 80,
  "lossless": false,
  "stripMetadata": true,
  "backgroundColor": "#ffffff",
  "width": 600,
  "height": 0,
  "fit": "inside",
  "resizePercent": 0,
  "allowUpscale": false,
  "targetSizeKb": 0,
  "shrinkToTarget": false,
  "maxImages": 100,
  "maxSourceSizeMb": 25,
  "concurrency": 4
}
```

# Actor output Schema

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

All result items of this run (the default dataset), as JSON, CSV, Excel and more.

## `records` (type: `string`):

Key-value store records: the run summary, notes on any problems, and any files.

# 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 = {
    "urls": [
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
        "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"
    ],
    "width": 600
};

// Run the Actor and wait for it to finish
const run = await client.actor("data-done-right/batch-image-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 = {
    "urls": [
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
        "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg",
    ],
    "width": 600,
}

# Run the Actor and wait for it to finish
run = client.actor("data-done-right/batch-image-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 '{
  "urls": [
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    "https://interactive-examples.mdn.mozilla.net/media/cc0-images/grapefruit-slice-332-332.jpg"
  ],
  "width": 600
}' |
apify call data-done-right/batch-image-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,data-done-right/batch-image-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/4WrghlLWKZSR67vOl/builds/MbDxX5FAFYgOupN2d/openapi.json
