# Image Converter: Resize, Compress, WebP and AVIF (`forgeloop/image-converter`) Actor

Convert, resize and compress images in bulk. JPEG, PNG, WebP, AVIF, GIF, TIFF and SVG in, WebP, AVIF, JPEG, PNG, GIF or TIFF out. Thumbnails and responsive sizes in one run, metadata stripped, EXIF rotation applied. Files land in the key-value store. Pay per produced file.

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

## Pricing

from $1.00 / 1,000 image produceds

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

## Image Converter: Resize, Compress, WebP and AVIF

Convert, resize and compress images in bulk. Give a list of image URLs or base64 data, pick an output format and a size, and get back one file per image in the run's key-value store plus one dataset row with the link, the new size and the bytes saved. Several sizes or formats per image in one run, for example thumbnails at 200, 800 and 1600 px as WebP.

Built for web performance work, e-commerce product images, CMS and newsletter pipelines, and automations in Make, Zapier or n8n that need a smaller or different image file. The conversion runs inside the Actor with [sharp](https://sharp.pixelplumbing.com) (libvips). No third-party image API, no browser.

### What it does

- **Converts** JPEG, PNG, WebP, AVIF, GIF, TIFF and SVG to WebP, AVIF, JPEG, PNG, GIF (static) or TIFF. "Same as source" keeps the format and only resizes or recompresses.
- **Resizes** to a width, a height or both, with the fit modes `inside` (no crop), `cover` (crop to fill), `contain` (pad), `outside` and `fill`. Crop position by edge or by content (`entropy`, `attention`). Images are never enlarged unless you allow it. SVG files are rendered at the target size, so they stay sharp.
- **Compresses** with a quality setting from 1 to 100, mozjpeg for JPEG, lossless WebP and AVIF for graphics, and an optional palette mode for PNG.
- **Variants:** up to 10 outputs per image in one run, each with its own label, size, format and quality.
- **Cleans up:** strips EXIF (camera, GPS location), XMP and color profiles by default, converts to sRGB and applies the EXIF orientation so photos stay upright.
- **Background color** for transparent areas in JPEG output, for the `contain` padding and for the optional flatten. Optional grayscale.
- **Stores the files** in the run's default key-value store and returns a direct link per file. Optional base64 in the row for files under 1 MB.
- **Safe downloads:** http and https only, private and local network addresses are blocked on every redirect, 25 MB size limit, download timeout, retries on HTTP 429 and 5xx. Web pages, videos and other non-image answers get a free error row.

### Use cases

- **Faster websites:** turn JPEG and PNG product or blog images into WebP or AVIF and cut their size by 30 to 90 percent.
- **Responsive images:** produce 400, 800 and 1600 px versions of each image for `srcset` in one run.
- **Thumbnails:** square 200 x 200 crops with smart crop (`attention`) for catalogs, galleries and previews.
- **Marketplace and shop feeds:** JPEG on a white background at a fixed size, metadata removed.
- **Privacy:** strip GPS and camera data from photos before you publish them.
- **Automations:** send base64 from a form or an email attachment, get the converted file back as a link or base64.

### Input

| Field | Description | Default |
|---|---|---|
| Image URLs | Direct links to image files, also Apify key-value store record URLs | |
| Base64 images | JSON array like `[{"name": "logo.png", "data": "iVBORw0..."}]`, data URIs work too | |
| Output format | `webp`, `avif`, `jpeg`, `png`, `gif`, `tiff` or `original` | `webp` |
| Width, Height | Target size in pixels, 1 to 10,000. Empty keeps the aspect ratio. | |
| Fit | `inside`, `cover`, `contain`, `outside`, `fill` | `inside` |
| Crop position | `centre`, edges and corners, `entropy`, `attention` | `centre` |
| Do not enlarge | Never upscale beyond the source size | on |
| Quality | 1 to 100 for WebP, AVIF, JPEG and palette PNG | 80 |
| Lossless (WebP, AVIF) | Encode without quality loss | off |
| Variants | JSON array of up to 10 outputs per image, fields as above plus `label` | |
| Strip metadata | Remove EXIF, XMP and color profile | on |
| Apply EXIF orientation | Rotate photos upright | on |
| Background color | Hex, rgb() or a name like `white` or `transparent` | `#ffffff` |
| Flatten transparency | Replace transparency with the background in every format | off |
| Grayscale | Black and white output | off |
| PNG with palette | Up to 256 colors, much smaller PNG files | off |
| Include base64 | Add the file as base64 to the row, files under 1 MB only | off |
| Max file size (MB) | Larger sources are skipped, 1 to 25 | 25 |
| Max concurrency | Images processed at the same time, 1 to 16 | 4 |
| Download timeout | Seconds per download, 5 to 300 | 60 |

Example, convert two images to WebP at most 1200 px wide:

```json
{
  "images": [
    "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
  ],
  "format": "webp",
  "width": 1200,
  "quality": 80
}
```

Example, three variants per image: a square smart-cropped thumbnail, a medium WebP and a large AVIF:

```json
{
  "images": ["https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg"],
  "variants": [
    { "label": "thumb", "width": 200, "height": 200, "fit": "cover", "position": "attention" },
    { "label": "medium", "width": 800 },
    { "label": "large", "width": 1600, "format": "avif", "quality": 60 }
  ]
}
```

### Output

One dataset row per produced file:

```json
{
  "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
  "sourceName": "Fronalpstock_big.jpg",
  "variant": "thumb",
  "format": "webp",
  "contentType": "image/webp",
  "width": 200,
  "height": 200,
  "bytes": 9690,
  "originalFormat": "jpeg",
  "originalWidth": 1280,
  "originalHeight": 575,
  "originalBytes": 221419,
  "savingsPercent": 95.6,
  "fileUrl": "https://api.apify.com/v2/key-value-stores/aBcD1234/records/001-Fronalpstock_big-thumb.webp?signature=xYz123",
  "key": "001-Fronalpstock_big-thumb.webp",
  "base64": null,
  "note": null,
  "error": null
}
```

- `fileUrl` opens the file directly, without an API token. The signature in the link grants read access to this one file. `key` is its name in the run's default key-value store: number of the source, file name, variant label and extension.
- `variant` is your label, or a generated one like `800w-webp` when you set none.
- `originalWidth` and `originalHeight` are the display size of the source after EXIF orientation. `originalBytes` is the size of the downloaded file.
- `savingsPercent` compares the output with the source file. It is negative when the output is larger, which happens when you convert small or already well compressed files.
- `sourceUrl` is empty for base64 input, `sourceName` then holds your name.
- `note` tells you when an animated GIF or WebP was reduced to its first frame, or when base64 was left out because the file is 1 MB or larger.
- A source that fails (download error, not an image, too large, refused platform) returns one row with `error` set and no charge. A variant that fails returns a row with `variant` and `error`.

Export the dataset as JSON, CSV or Excel, or read it through the Apify API.

### Pricing

Pay per produced file: 0.001 USD per file, so 1.00 USD per 1,000 files. Three variants of one image are three files. Errors, refused links, non-image URLs and files over the limit are free. Set the maximum charge per run in Apify to cap the cost: the Actor stops before it produces a file that the limit cannot pay for.

Each run also has a start fee of 0.00005 USD per GB of memory, which Apify shows as Actor Start.

### Limits

- At most 1,000 images per run and 10 variants per image. Extra images get one free error row.
- At most 25 MB and 100 megapixels per source image.
- HEIC/HEIF photos from iPhones, BMP, ICO, JPEG XL, PDF and RAW files are not supported.
- GIF output is a single frame. Animated GIF and WebP input is converted from the first frame.
- AVIF encoding is slower than WebP. Large AVIF variants of big photos can take a few seconds each.
- Only direct links to image files. Pages of video, social media and photo sharing platforms (YouTube, Instagram, TikTok, X, Facebook, Pinterest, Flickr, Imgur and the like) are refused.
- Base64 input counts toward the Apify input size limit of a few MB. Use URLs for large batches.
- The default 512 MB memory handles typical web images with 4 in parallel. Apify gives a run CPU in proportion to its memory, so very large photos are slow at 512 MB: a 46 megapixel JPEG converted to a full size WebP takes about a minute, resized to 1920 px a few seconds. For many photos above 30 megapixels, give the run 1 to 2 GB of memory or lower Max concurrency.

### Data source, permitted use and legal

- **Data source:** The images you provide as links or base64. The Actor downloads each link once and converts it with the open source library sharp (libvips). Nothing is sent to a third-party service.
- **Snapshot:** Results show the source at the time of the run. We do not guarantee that they are complete, current or correct.
- **For business use:** This Actor is offered to businesses only, not to consumers.
- **Permitted use:** Convert only images you own or have the right to process. Respect the copyright and the terms of the sites you download from. Produced files are stored in your Apify account and follow its data retention.
- **Your responsibility:** You choose the images and decide what happens with the results. If your images contain personal data, for example faces or GPS data in EXIF, you are the controller and need your own legal basis. Metadata is stripped by default.
- **No circumvention:** The Actor uses plain HTTP downloads without login. It does not bypass paywalls, logins, rate limits, blocks or access restrictions, and refuses links to video and social media platforms.
- **Request volume:** One download per image, at most 16 at the same time, up to 3 attempts with backoff on HTTP 429 and 5xx. Do not use it to put excessive load on a server.
- **Provider:** forgeloop, Markus Heiss, Austria. [Imprint](https://devhem.github.io/forgeloop-legal/imprint.html), [Privacy Notice](https://devhem.github.io/forgeloop-legal/privacy.html), [Terms of Use](https://devhem.github.io/forgeloop-legal/terms.html).

### Questions and issues

Open an issue on the Actor page.

# Actor input Schema

## `images` (type: `array`):

Direct http(s) links to image files you are allowed to use: JPEG, PNG, WebP, AVIF, GIF, TIFF or SVG. Links to records in your Apify key-value stores (https://api.apify.com/v2/key-value-stores/.../records/...) work too. Links to video, social media and photo sharing platforms (YouTube, Instagram, TikTok, Pinterest, Flickr and the like) are refused. Format: a list of strings like \["https://example.com/photo.jpg"].

## `base64Images` (type: `array`):

Optional. Images as base64 inside the input, for small files from automations. A JSON array of objects like \[{"name": "logo.png", "data": "iVBORw0KGgo..."}]. data can also be a data URI (data:image/png;base64,...). The Apify input is limited to a few MB in total, so use Image URLs for large files.

## `format` (type: `string`):

Format of the produced files. WebP and AVIF give the smallest files and work in all current browsers. "original" keeps the format of each source image (SVG becomes PNG). GIF output is a single frame.

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

Target width in pixels. Leave empty to keep the width or to follow the height with the same aspect ratio.

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

Target height in pixels. Leave empty to keep the height or to follow the width with the same aspect ratio.

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

How the image fits into width x height when both are set. inside: as large as possible within the box, aspect ratio kept, no crop. cover: fills the box and crops the rest. contain: fits into the box and pads with the background color. outside: at least as large as the box. fill: stretches to the exact size.

## `position` (type: `string`):

Which part to keep when fit is cover, or where to place the image when fit is contain. entropy and attention pick the most detailed or most striking region (cover only).

## `withoutEnlargement` (type: `boolean`):

Never make an image larger than the source. A 600 px wide image stays 600 px when you ask for 1600 px.

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

1 to 100 for WebP, AVIF and JPEG, and for PNG with palette. Lower means smaller files. 75 to 85 looks good for photos on the web.

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

Encode WebP and AVIF without any quality loss. Good for logos, screenshots and graphics. Files are larger than lossy ones. PNG, GIF and TIFF are always lossless, JPEG never.

## `variants` (type: `array`):

Optional. Several outputs per image in one run, for example thumbnails and responsive sizes. A JSON array of up to 10 objects. Each object can set label, width, height, format, quality, fit, position, lossless, withoutEnlargement, grayscale and flatten. Missing fields come from the settings above. Example: \[{"label": "thumb", "width": 200}, {"label": "medium", "width": 800}, {"label": "large", "width": 1600, "format": "avif"}]. Each produced file is one charged item.

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

Remove EXIF (camera, GPS location, date), XMP and the color profile. Colors are converted to sRGB first. Turn it off to keep the metadata.

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

Rotate photos the way the camera recorded them (EXIF orientation), so they look upright everywhere. Turn it off only if you know why.

## `background` (type: `string`):

Fills transparent areas when the output has no transparency (JPEG) or when Flatten is on, and pads the image when fit is contain. Hex like "#ffffff", rgb(255,255,255) or a name like "white" or "transparent".

## `flatten` (type: `boolean`):

Replace transparency with the background color for every output format, not only JPEG.

## `grayscale` (type: `boolean`):

Convert to black and white.

## `pngPalette` (type: `boolean`):

Reduce PNG output to at most 256 colors with dithering, like TinyPNG. Often 60 to 80 percent smaller. Quality controls how many colors are kept. Off: full color PNG.

## `includeBase64` (type: `boolean`):

Add the produced file as base64 to each dataset item, for automations that cannot download files. Only for files under 1 MB, larger files get a note instead.

## `maxFileSizeMb` (type: `integer`):

Larger source images are skipped with an error item and are not charged. At most 25 MB. Images above 100 megapixels are skipped too.

## `maxConcurrency` (type: `integer`):

How many images are downloaded and converted at the same time. Higher is faster for many small images. Lower it if large images run out of memory.

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

Give up on a download that takes longer than this. The image gets a free error item.

## Actor input object example

```json
{
  "images": [
    "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
  ],
  "format": "webp",
  "fit": "inside",
  "position": "centre",
  "withoutEnlargement": true,
  "quality": 80,
  "lossless": false,
  "stripMetadata": true,
  "autoRotate": true,
  "background": "#ffffff",
  "flatten": false,
  "grayscale": false,
  "pngPalette": false,
  "includeBase64": false,
  "maxFileSizeMb": 25,
  "maxConcurrency": 4,
  "downloadTimeoutSecs": 60
}
```

# Actor output Schema

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

No description

## `files` (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 = {
    "images": [
        "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("forgeloop/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 = { "images": [
        "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
        "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("forgeloop/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 '{
  "images": [
    "https://upload.wikimedia.org/wikipedia/commons/thumb/3/3f/Fronalpstock_big.jpg/1280px-Fronalpstock_big.jpg",
    "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png"
  ]
}' |
apify call forgeloop/image-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,forgeloop/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/TtkHrEorL8uhufbdY/builds/24l6FlnzNnVQ9CCcs/openapi.json
