# Image Converter & Compressor: WebP, AVIF, JPEG, PNG (`adam-frank/image-converter`) Actor

Convert and compress images from URLs to WebP, AVIF, JPEG or PNG, with optional resizing. Returns a download link plus before/after size for each image. Bad URLs become error rows and are never charged. Works from AI agents via Apify MCP.

- **URL**: https://apify.com/adam-frank/image-converter.md
- **Developed by:** [Adam Schepis](https://apify.com/adam-frank) (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

$2.00 / 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.

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 & Compressor: WebP, AVIF, JPEG, PNG

Convert and compress images in bulk from their URLs. Give it a list of **image links** (JPEG, PNG, WebP, AVIF, GIF or TIFF) and pick an output format: **WebP, AVIF, JPEG or PNG**, or keep each image's own format and just compress it. Optionally shrink images to fit a maximum width and height.

For every URL you get one dataset row with a **download link to the converted file**, the input and output format, the **size before and after**, the percentage saved, and the final dimensions. A link that fails becomes an error row that says why, the rest of the batch carries on, and **failed images are never charged**.

Works from AI agents too: call it as a tool through [Apify's MCP server](https://mcp.apify.com) to convert or shrink an image mid-conversation and hand back a link.

### What you get

- **WebP, AVIF, JPEG or PNG output**, or "keep" to re-compress in the original format.
- **Resize without distortion:** set `maxWidth` and/or `maxHeight` and each image is scaled down to fit inside that box, aspect ratio kept. Small images are never enlarged.
- **Photos come out the right way up.** The EXIF orientation tag is applied to the pixels, so phone photos don't turn up sideways after conversion.
- **Metadata stripped by default:** camera data, GPS location and timestamps are removed, which makes files smaller and keeps photo locations private. Turn `stripMetadata` off to keep them.
- **Clear results for every URL:** an `ok` row with a download link and sizes, or an `error` row with a code and a plain-English reason. One bad link never fails the run.
- **Animated GIFs:** converting to WebP keeps the animation. Converting to JPEG, PNG or AVIF keeps the first frame, and the row's `note` says so.
- **Pay only for converted images**, charged after the file is saved.

Built on [sharp](https://sharp.pixelplumbing.com/) (libvips), with mozjpeg for JPEG output.

### Input

| Field | Type | Required | Description |
|---|---|---|---|
| `imageUrls` | array of URLs | yes | Public http/https links to image files, up to 25 MB and 50 megapixels each. |
| `format` | string | no (default `webp`) | `webp`, `avif`, `jpeg`, `png`, or `keep` to re-encode in the input's own format. |
| `quality` | integer 1-100 | no (default 80) | Lower is smaller with more visible compression. Not used for PNG, which is lossless. |
| `maxWidth` | integer | no | Shrink images wider than this. Never enlarges. |
| `maxHeight` | integer | no | Shrink images taller than this. With both set, the image fits inside the box. |
| `stripMetadata` | boolean | no (default `true`) | Remove EXIF, XMP and IPTC data from the output. |
| `maxResults` | integer | no (default 1000) | Process at most this many URLs; the rest are skipped and not charged. |

Example input:

```json
{
    "imageUrls": [
        { "url": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg" },
        { "url": "https://upload.wikimedia.org/wikipedia/commons/a/a9/Example.jpg" }
    ],
    "format": "jpeg",
    "quality": 75,
    "maxWidth": 400
}
```

### Output example

One row per input URL. This is a real row from a run of the input above:

```json
{
    "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg",
    "status": "ok",
    "error": null,
    "errorMessage": null,
    "outputUrl": "https://api.apify.com/v2/key-value-stores/S7QfUXsXl2oXB1M3G/records/image-0001-Apollo-11-first-step.jpg?signature=16V31efH90vTunVgw3Jy1",
    "outputKey": "image-0001-Apollo-11-first-step.jpg",
    "inputFormat": "jpeg",
    "outputFormat": "jpeg",
    "inputBytes": 87083,
    "outputBytes": 9857,
    "savingsPercent": 88.7,
    "width": 400,
    "height": 304,
    "animated": false,
    "note": null,
    "processedAt": "2026-11-20T01:35:35.835Z"
}
```

A URL that fails produces the same shape with `status: "error"` and nothing in the output fields:

```json
{
    "sourceUrl": "https://example.com/",
    "status": "error",
    "error": "not-an-image",
    "errorMessage": "The URL returned text/html content, not an image.",
    "outputUrl": null,
    "outputKey": null,
    "inputBytes": 577,
    "outputBytes": null,
    "savingsPercent": null
}
```

The converted files are saved in the run's default key-value store under `outputKey`; `outputUrl` downloads the file directly. Download the rows as JSON, CSV or Excel, or read them through the Apify API.

#### Error codes

| `error` | Meaning |
|---|---|
| `invalid-url` | Not a valid URL, or it has a username/password in it. |
| `blocked-scheme` | Not http or https. |
| `blocked-address` | The host is, or resolves to, a private, loopback, link-local or reserved network address. Checked again on every redirect. |
| `unreachable` | DNS failed or the server could not be reached. |
| `http-error` | The server answered with an error status, such as 404 or 403. |
| `timeout` | The download took longer than 30 seconds. |
| `too-many-redirects` | More than 5 redirects. |
| `file-too-large` | The file is over 25 MB. |
| `not-an-image` | The URL returned something that is not an image, such as an HTML page. |
| `unsupported-format` | An image format this Actor does not read, such as SVG or HEIC. |
| `image-too-large` | Over 50 megapixels (all frames counted, when an animation is kept). |
| `conversion-failed` | The image is damaged or could not be encoded. |

### Pricing

This Actor uses [pay-per-event pricing](https://docs.apify.com/platform/actors/publishing/monetize/pay-per-event). You pay for one event, `image-converted`, once per image that was converted and saved. The exact price is shown on the Actor's Store page before you run it.

| Event | When it's charged |
|---|---|
| `image-converted` | Once per image, after the converted file is saved to the key-value store and its row is in the dataset. |

- **Error rows are free.** A URL that fails to download, isn't an image, or fails to convert is never charged.
- **Your spending limit is respected.** When the run's maximum cost is reached, the Actor stops before starting another image.

### Good to know

- **Savings depend on the source.** Shrinking a large image or converting a PNG photo gives big savings. Re-encoding a full-size JPEG that is already well compressed may save little, and PNG output from a photo is usually larger than the JPEG it came from; `savingsPercent` is negative when that happens. In our test runs, a 4073752-byte PNG became an 81865-byte AVIF at 800 px wide (98% smaller), while a 2684586-byte, 4335x2990 JPEG scan re-encoded to WebP at full size and quality 80 became 2496334 bytes (7% smaller).
- **JPEG has no transparency:** transparent areas become white.
- **Images are processed one at a time**, in the order given.
- **The link must be publicly reachable.** The Actor downloads each file itself, so links behind a login, or hosts that block automated downloads, will fail with an error row.
- **Private network addresses are refused** for safety, including links that redirect to one.
- **Sharing `outputUrl`:** the link points at the file in the run's key-value store and opens without an API token. If your account restricts storage access, the link includes a `signature` parameter that unlocks that one file. Files live as long as the run's storage is retained on your plan, so copy them somewhere permanent if you need them long term.

### Why this Actor

- Every URL gets a row that says exactly what happened, and a bad URL never fails the whole batch.
- You see the size before and after for each image, so you know what the conversion bought you.
- EXIF rotation, transparent-to-JPEG and animated GIFs are handled deliberately, not left to chance.

### Notes

- Built with [sharp](https://github.com/lovell/sharp) (Apache-2.0) and the [Apify SDK for JavaScript](https://docs.apify.com/sdk/js/).
- Sample images in the default input are public-domain files from Wikimedia Commons: Hokusai's *The Great Wave off Kanagawa*, NASA's *Earth Western Hemisphere*, and NASA's *Apollo 11 first step*.

# Actor input Schema

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

Public http or https links to image files: JPEG, PNG, WebP, AVIF, GIF or TIFF, up to 25 MB and 50 megapixels each. A link that fails, points at a private network address, or returns something other than an image becomes an error row in the dataset and is not charged.

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

WebP is the safe default for websites: small files that every current browser shows. AVIF is usually smaller still but slower to encode. JPEG suits photos for email and older tools; transparent areas become white. PNG is lossless and ignores the quality setting. "Keep" re-encodes each image in its own format, which is how you compress without converting.

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

1-100. Lower means smaller files with more visible compression. 75-85 is a good range for photos on the web. Not used for PNG output, which is always lossless.

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

Shrink images wider than this, keeping the aspect ratio. Images are never enlarged. Leave empty to keep the original size.

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

Shrink images taller than this, keeping the aspect ratio. With both limits set, the image fits inside the box. Images are never enlarged.

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

Remove EXIF (camera, GPS location, timestamps), XMP and IPTC data from the output. On by default: it makes files smaller and keeps photo locations private. Rotation from the EXIF orientation tag is applied to the pixels either way, so photos never come out sideways.

## `maxResults` (type: `integer`):

Process at most this many URLs from the list; the rest are skipped and not charged.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/0/0a/The_Great_Wave_off_Kanagawa.jpg"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/2/22/Earth_Western_Hemisphere_transparent_background.png"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg"
    }
  ],
  "format": "webp",
  "quality": 80,
  "stripMetadata": true,
  "maxResults": 1000
}
```

# Actor output Schema

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

Dataset with one row per image URL: status, download link, formats and sizes before and after.

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

Key-value store holding the converted image 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 = {
    "imageUrls": [
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/0/0a/The_Great_Wave_off_Kanagawa.jpg"
        },
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/2/22/Earth_Western_Hemisphere_transparent_background.png"
        },
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("adam-frank/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 = { "imageUrls": [
        { "url": "https://upload.wikimedia.org/wikipedia/commons/0/0a/The_Great_Wave_off_Kanagawa.jpg" },
        { "url": "https://upload.wikimedia.org/wikipedia/commons/2/22/Earth_Western_Hemisphere_transparent_background.png" },
        { "url": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("adam-frank/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 '{
  "imageUrls": [
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/0/0a/The_Great_Wave_off_Kanagawa.jpg"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/2/22/Earth_Western_Hemisphere_transparent_background.png"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/1/1e/Apollo_11_first_step.jpg"
    }
  ]
}' |
apify call adam-frank/image-converter --silent --output-dataset

```

## MCP server setup

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