# Image Converter & Compressor - WebP, AVIF, JPG, PNG in Bulk (`northbell/image-converter`) Actor

Convert, compress and resize image links in bulk: WebP, AVIF, JPG, PNG. Strips EXIF and GPS data by default. Results are files in the run's key-value store with public links.

- **URL**: https://apify.com/northbell/image-converter.md
- **Developed by:** [Northbell](https://apify.com/northbell) (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.60 / 1,000 images

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

## Image Converter & Compressor - WebP, AVIF, JPG, PNG in Bulk

**Convert, compress and resize image links in bulk.** Give it direct links to images (or a dataset from another Actor) and get WebP, AVIF, JPEG or PNG back as files with public links, one dataset row per image. EXIF and GPS data are removed by default. One bad image never fails the run: it becomes a row with a plain error message, and the rest carry on.

**Try it now — the input is already filled in.** Press **Start**. It converts two NASA photos (public domain: an Apollo 11 photograph and a Galileo image of the Earth and Moon, from images-assets.nasa.gov) to WebP at quality 80. In our own local run with this input: **384,920 bytes in, 298,252 bytes out (22.5% smaller), about 3 seconds** including the downloads. Both outputs are under 25 megapixels, so they are billed as 2 images: **$0.004** (plus $0.00005 for the run start).

### What you pay

| Event | Price | When |
| --- | --- | --- |
| `image` | $0.002 | per converted image, output up to 25 megapixels |
| `large-image` | $0.006 | per converted image, output above 25 megapixels |
| `apify-actor-start` | $0.00005 | once per run |

- You are charged for an image only after the result is saved. Errors, rejected links, images skipped by "Only new images" and images that could not be converted are free.
- Set "Maximum total charge" on the run as your cap. The Actor checks the charge limit before it stores each image and stops cleanly when the next one does not fit.

### Built so that runs finish

- **A timeout on every image.** Downloads give up after 20 seconds without data or 60 seconds in total; download plus conversion is cut off at 120 seconds. A hung server costs you one error row, not the run.
- **Retries.** A 429, a 5xx answer or a dropped connection is tried again twice (after 1 and 3 seconds, or the server's `Retry-After` up to 10 seconds). A 404, a login page or a corrupt file is an error straight away.
- **Errors are rows.** Each failed image gets `status: "error"` and a sentence that says why (for example "The server answered 404." or "The file is damaged or not an image this tool can read"). The run still ends as succeeded.
- **Bounded parallelism.** 4 images at a time by default, up to 8 (`concurrency`).
- **Size caps.** Inputs above `maxFileMb` (50 MB by default) and images above 100 megapixels are refused before decoding.

### Run it after your scraper

If another Actor collects image links (a product scraper, a real-estate scraper, a news scraper), this Actor can convert them automatically after every run of it:

1. In Apify Console, open that Actor and go to **Integrations**.
2. Add **Run Actor** (on "Run succeeded") and pick this Actor.
3. Use an input like this, with the name of the field that holds the image link or links:

```json
{
  "datasetId": "{{resource.defaultDatasetId}}",
  "urlField": "images",
  "format": "webp",
  "quality": 80,
  "maxWidth": 1600,
  "onlyNewImages": true
}
```

Each run of the first Actor then hands over its dataset, and every link in it is converted. The field can hold one link or a list of links (`images` holding an array is the usual product-scraper shape): every link in the list is converted. A dotted path such as `media.photos` reaches into nested fields, and a list of objects with a `url` field works too. If the dataset has no links, nothing runs and nothing is charged. Each output row keeps a small `sourceItem` (the field name, the link and the row's `id` if it has one) so you can match results to the original rows.

### Run it on a schedule with only new images

Turn on `onlyNewImages` and schedule the run. The Actor keeps a list of what it has converted in a key-value store named `image-converter-seen` in your account, keyed by a hash of the link and the output settings. On the next run, links already converted with the same settings come back as `status: "skipped"` rows and are not charged; change the format, quality, size or any other output setting and the images are converted again. Images that were not processed (for example because of `maxItems` or a charge limit) are not marked as done, so the next run picks them up. The list is saved at the end of the run. If the store cannot be opened, the run stops before charging anything.

### Formats and options

| Input | Default | What it does |
| --- | --- | --- |
| `imageUrls` | two NASA photos | direct links to images (JPEG, PNG, WebP, AVIF, GIF, TIFF) |
| `datasetId`, `urlField` | - , `url` | read links from another Actor's dataset; dotted paths and lists allowed |
| `onlyNewImages` | off | skip links already converted with the same settings |
| `format` | `webp` | `webp`, `avif`, `jpeg`, `png`, or `keep` (same format as the input) |
| `quality` | 80 | 1 to 100, for WebP, AVIF and JPEG; for PNG it sets the palette quality |
| `lossless` | off | WebP and PNG only: exact pixels, larger files |
| `targetKb` | none | find the highest quality that gives a file at or under this size (at most 6 tries) |
| `maxWidth`, `maxHeight` | none | scale down to fit |
| `fit` | `inside` | `inside` keeps the ratio; `cover` fills the box and crops; `contain` fits and pads (transparent, white for JPEG) |
| `withoutEnlargement` | on | never scale a small image up |
| `keepMetadata` | off | keep EXIF, GPS and camera data (off removes them) |
| `maxItems` | 500 | images per run (links and dataset together) |
| `maxFileMb` | 50 | largest input and largest result in MB (hard cap 200) |
| `concurrency` | 4 | images at the same time, 1 to 8 |

Notes:

- **Metadata.** Orientation is always applied: a photo that a camera stored sideways comes out upright, and the orientation tag is not kept. With the default settings, EXIF, GPS location and camera data are removed. The colour is converted to sRGB.
- **Transparency.** WebP, AVIF and PNG keep it. JPEG has none, so transparent areas become white.
- **PNG.** With `lossless` off, PNG output is a palette image (up to 256 colours) at the chosen quality, which is much smaller for graphics and screenshots. Turn `lossless` on for exact pixels.
- **Target size.** With `targetKb`, the Actor tries your quality first (a file that already fits is kept), then the lowest quality (if even that is too big, it stops and reports `targetReached: false` with the smallest file), then searches in between. It never resizes; set `maxWidth` too if you need a smaller file than quality alone can reach. For lossless output and GIF there is nothing to search: the row just says whether the file is under the target.
- **Animated WebP and GIF** stay animated when the output is WebP or GIF. Other outputs use the first frame.
- **HEIC/HEIF photos (iPhone) are not supported.** The image library cannot decode HEVC, so these come back as an error row, free. AVIF input works. SVG input is refused too.

### Output

One dataset row per input. The converted file is stored in the run's key-value store, and `outputUrl` is its public link.

```json
{
  "inputUrl": "https://images-assets.nasa.gov/image/PIA00342/PIA00342~medium.jpg",
  "status": "ok",
  "error": null,
  "outputUrl": "https://api.apify.com/v2/key-value-stores/a097d3f8-5d45-4f91-859e-fc148d32c181/records/PIA00342-medium-34d12036.webp",
  "outputKey": "PIA00342-medium-34d12036.webp",
  "format": "webp",
  "width": 1005,
  "height": 1280,
  "inputBytes": 122699,
  "outputBytes": 77590,
  "savedPercent": 36.8,
  "quality": 80
}
```

This row is from our local run of the prefilled input; the store id in the link is the one that run used on our machine. On Apify it is your run's store. With `targetKb` set, rows also carry `targetReached` (true or false). For a failed input, `status` is `error`, `error` says why in plain words, and `outputUrl` is `null`. For a skipped one, `status` is `skipped`. The result files stay as long as your Apify storage retention keeps the run.

### Limits

- Direct image links only. A link that returns a web page is an error (free). Links to private or local network addresses are rejected.
- The image must be reachable without a login. Some sites block automated downloads; those links come back as errors with the server's answer.
- Size caps: `maxFileMb` for the input and the result (50 MB by default, 200 MB at most), and 100 megapixels for the input.
- Your images are processed only inside this Actor's run on Apify; nothing is sent to other services.
- You are responsible for having the right to convert the images you give it.

### 日本語

画像への直リンク(または他の Actor のデータセット)を、WebP・AVIF・JPEG・PNG に一括で変換・圧縮・リサイズします。結果は実行のキー・バリューストアに保存され、公開リンクが画像1枚につき1行のデータセットで返ります。EXIF・GPS 情報は既定で削除(向きは反映)。目標サイズ(KB)の指定、前回までに変換済みの画像をスキップする設定にも対応。料金は1枚 $0.002(出力 2,500 万画素以下)、2,500 万画素超は $0.006。保存できた分だけ課金され、失敗・スキップは無料です。1枚ごとにタイムアウトとリトライがあり、壊れた画像があっても実行全体は失敗しません。iPhone の HEIC/HEIF には対応していません。変換する画像の権利はご自身でご確認ください。

# Actor input Schema

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

Direct links to image files (JPEG, PNG, WebP, AVIF, GIF, TIFF). Or leave empty and give a Dataset ID. HEIC/HEIF photos and SVG files come back as errors, free.

## `datasetId` (type: `string`):

Read image links from this Apify dataset (e.g. the dataset of a scraper run). Use {{resource.defaultDatasetId}} when you connect this Actor as an integration after another Actor.

## `urlField` (type: `string`):

Name of the field that holds the image link. A dotted path works (media.image). The field may hold one link or a list of links, for example images; every link is converted.

## `onlyNewImages` (type: `boolean`):

Skip links this Actor already converted with the same output settings in an earlier run (kept in a key-value store named image-converter-seen in your account). Use it for scheduled runs. Skipped images are free.

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

keep writes JPEG, PNG, WebP or GIF as the same format (an AVIF stays AVIF).

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

WebP, AVIF and JPEG. For PNG it sets the colour palette quality unless Lossless is on.

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

WebP and PNG only: keep every pixel exactly. Files are larger. Ignores Quality (and the target size).

## `targetKb` (type: `number`):

Optional. Searches for the highest quality that gives a file at or under this size, in at most 6 tries. Each row says whether the target was reached; if not, you get the smallest file found. Does not resize.

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

Scales the image down to fit. Empty keeps the width.

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

Scales the image down to fit. Empty keeps the height.

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

How the image meets the maximum width and height. Cover and contain make the picture exactly width x height when both are set.

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

Do not scale a small image up to the maximum width or height.

## `keepMetadata` (type: `boolean`):

Off by default: EXIF, GPS location and camera data are removed (the picture is still turned upright by its orientation). Turn on to keep them.

## `maxItems` (type: `integer`):

Cap on images per run, counting the links above and the dataset together (images skipped by Only new images do not count). Images over the cap are left for the next run.

## `maxFileMb` (type: `integer`):

Larger inputs, and results larger than this, come back as errors, free. Hard cap 200.

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

How many images are downloaded and converted in parallel (1 to 8).

## Actor input object example

```json
{
  "imageUrls": [
    "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~medium.jpg",
    "https://images-assets.nasa.gov/image/PIA00342/PIA00342~medium.jpg"
  ],
  "urlField": "url",
  "onlyNewImages": false,
  "format": "webp",
  "quality": 80,
  "lossless": false,
  "fit": "inside",
  "withoutEnlargement": true,
  "keepMetadata": false,
  "maxItems": 500,
  "maxFileMb": 50,
  "concurrency": 4
}
```

# Actor output Schema

## `images` (type: `string`):

Status, result link, sizes and quality per input.

# 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-assets.nasa.gov/image/as11-40-5903/as11-40-5903~medium.jpg",
        "https://images-assets.nasa.gov/image/PIA00342/PIA00342~medium.jpg"
    ],
    "format": "webp"
};

// Run the Actor and wait for it to finish
const run = await client.actor("northbell/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": [
        "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~medium.jpg",
        "https://images-assets.nasa.gov/image/PIA00342/PIA00342~medium.jpg",
    ],
    "format": "webp",
}

# Run the Actor and wait for it to finish
run = client.actor("northbell/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": [
    "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~medium.jpg",
    "https://images-assets.nasa.gov/image/PIA00342/PIA00342~medium.jpg"
  ],
  "format": "webp"
}' |
apify call northbell/image-converter --silent --output-dataset

```

## MCP server setup

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