# Image Converter & Compressor: WebP, AVIF, JPEG, PNG in Bulk (`klarto/image-converter`) Actor

Image converter and compressor: convert JPEG, PNG, GIF, TIFF and WebP images from links or dataset fields to WebP, AVIF, JPEG or PNG, resized, with GPS/EXIF removed, plus one ZIP link. Responsive sizes and a KB target. $0.002 per image up to 16 MP, lossless +$0.0025 per started 4 MP; failed free.

- **URL**: https://apify.com/klarto/image-converter.md
- **Developed by:** [Klarto](https://apify.com/klarto) (community)
- **Categories:** Developer tools, Automation, Integrations
- **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 converted 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, JPEG, PNG in Bulk

**Image converter and compressor** for Apify: convert JPEG, PNG, GIF, TIFF, BMP, AVIF and WebP images from links or from a field of your datasets to **WebP, AVIF, JPEG or PNG**, resized and with GPS/EXIF data removed, and get one ZIP link for all files. **$0.002 per converted image** up to 16 megapixels (a 12 MP phone photo at full size); bigger files pay $0.002 per further started 16 MP. Lossless output (PNG or lossless WebP) adds $0.0025 per started 4 MP. Failed and unsupported images are free.

Why use it:

- **Smaller files for the web.** WebP and AVIF output, quality you choose, and an optional size target in KB: the highest quality from 20 up to yours that fits is used, and the row's note says when none fits.
- **Responsive sizes in one run.** Give widths such as `[480, 960, 1600]` and get one file per width for a `srcset`.
- **Privacy by default.** EXIF, XMP and comments (camera, GPS position, dates) are removed; the photo is turned upright first and the color profile is kept.
- **Works after scrapers.** Pick a dataset and the field with the image links (for example the `fileUrl` of Bulk File Downloader or `images.*.url` of a scraper).
- **Safe with any link.** Only public addresses, every redirect checked, sizes and pixels capped, conversions in separate processes with a time limit.

### What it does

- **Input:** image links in `images`, or `datasets` with the fields that hold the links (`imageFields`).
- **Reads:** JPEG (also MPO from phones), PNG, WebP, GIF, TIFF, BMP, AVIF and ICO. HEIC, SVG and camera RAW files are not supported: they get a row with status `error` and are free. RAW files are recognised by the file name (.dng, .nef, .cr2 …), the Content-Type (image/x-nikon-nef …), the DNG tag, or a TIFF that starts with a reduced-size preview.
- **Writes:** WebP, AVIF, JPEG or PNG, or the same format as the source (GIF, TIFF, BMP and ICO become PNG). Animated GIF, WebP, PNG and AVIF stay animated in WebP, AVIF or PNG output (up to 300 frames, within the memory budget). Multi-page TIFF: the first page. MPO photos from phones: the main picture.
- **Output:** the files in the run's key-value store (keys `img-00001-<name>.<ext>`), one dataset row per output file, and an `OUTPUT` summary with a `zipUrl` that downloads all files as one ZIP.

### How it works

1. **Collect the links.** From `images` first, then from your datasets, each link once, up to `maxImages`. A value in `images` that is not an http(s) link gets an `error` row.
2. **Download safely.** The host must resolve to a public IP; private, loopback and cloud metadata addresses are refused, and every redirect is checked again. Answers that are not images (HTML, SVG) are refused before the body is read. HTTP 408, 425, 429, 500, 502, 503, 504 and dropped connections get 2 more tries.
3. **Check before decoding.** Pillow opens only the formats above. The size in the file header (also of images inside ICO files and of animation frames) is checked against the run's memory before the pixels are decoded: about 32 bytes per source pixel (twice that for transparent images), all frames of an animation counted, and about 56 bytes per AVIF output pixel (70 with transparency). A small file that claims a huge size is refused. Damaged files get a row with the reason.
4. **Convert.** In a child process with a time limit (`timeoutSecs`, counted from when a process is free): EXIF orientation applied, palette and transparency expanded, CMYK turned into sRGB with its own color profile, resized with Lanczos (never enlarged), alpha flattened onto `background` for JPEG, encoded with Pillow 13 (libwebp, libavif, libjpeg).
5. **Save, then charge.** Each file is uploaded to the key-value store, its row is written (`billable: true`), and only then charged. After a restart, saved rows are matched to their link by `sourceId`, never by position, so nothing is converted or charged twice.

The User-Agent is `KlartoImageConverter/0.1 (+https://apify.com/klarto)`. The Actor keeps no cookies. Your images are processed in the run only; they are not sent to any outside service.

### Input

| Field | Default | What it does |
|---|---|---|
| `images` | — | Direct image links, one per line. |
| `datasets` / `imageFields` | — / `["url"]` | Datasets whose rows hold image links, and the fields: `imageUrl`, `images.0`, `images.*.url`. |
| `format` | `webp` | `webp`, `avif`, `jpeg`, `png` or `same`. |
| `quality` | 80 | 1–100 for WebP, AVIF and JPEG. |
| `maxKb` | 0 | Size target in KB (1 KB = 1,024 bytes) for WebP (not lossless), AVIF and JPEG: the quality is lowered from `quality`, never below 20, and a `quality` of 20 or less is kept as it is; the row's `note` says when the target was not reached. 0 = none. |
| `maxWidth` / `maxHeight` | 0 / 0 | Shrink to fit; 0 = no limit. Never enlarges. |
| `fit` | `inside` | `inside` (no crop), `cover` (crop the center to the box), `contain` (pad to the box). Cover and contain need both sizes. |
| `widths` | — | Several widths per image, e.g. `[480, 960, 1600]`; each width is one file. Widths not smaller than the image are made once at the original size. |
| `stripMetadata` | `true` | Remove EXIF, XMP and JPEG comments (GPS, camera, dates). |
| `keepAnimation` | `true` | Keep animated images animated (WebP, AVIF, PNG output). |
| `lossless` | `false` | Lossless WebP; adds `lossless-4mp`. Not available for AVIF. |
| `background` | `#ffffff` | For transparent areas in JPEG and the border of `contain`. |
| `maxImages`, `maxFileSizeMb`, `timeoutSecs`, `maxConcurrency` | 1,000, 50, 120, 4 | Limits. |

Minimal input:

```json
{ "images": ["https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg"], "format": "webp", "maxWidth": 1920 }
```

Responsive AVIF set from a dataset:

```json
{ "datasets": ["<datasetId>"], "imageFields": ["imageUrl"], "format": "avif", "widths": [480, 960, 1600] }
```

### Output

A real row from a platform run (2026-11-19; the signed link shortened):

```json
{
  "imageIndex": 0,
  "sourceId": "2603a5a56ea62a1f7376",
  "url": "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
  "variant": null,
  "status": "ok",
  "error": null,
  "note": null,
  "sourceFormat": "JPEG",
  "sourceWidth": 5189,
  "sourceHeight": 5067,
  "sourceBytes": 3183792,
  "format": "webp",
  "width": 5189,
  "height": 5067,
  "frames": 1,
  "bytes": 1693140,
  "savedPercent": 46.8,
  "quality": 80,
  "fileName": "as11-40-5903_orig.webp",
  "key": "img-00001-as11-40-5903_orig.webp",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/4YeMskdATk0y0K4qH/records/img-00001-as11-40-5903_orig.webp?signature=…",
  "metadataRemoved": true,
  "finalUrl": "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
  "httpStatus": 200,
  "sources": ["input"],
  "billable": false,
  "ms": 2463,
  "convertedAt": "2026-11-19T13:53:59Z"
}
```

(`billable` was false because prices were not set yet in that run; `sourceId` and the name `billable` come from the current build, the other values from that run.)

| Field | Type | Meaning |
|---|---|---|
| `status` | text | `ok`, `error` (not converted: the reason is in `error`) or `skipped` (not saved and free: the run's timeout, or the run's maximum charge — an image is skipped for the charge only when its full price, extra 16 MP blocks included, is more than what is left of the maximum charge; the `error` states both amounts, and smaller images after it still run). |
| `fileUrl`, `key`, `fileName` | text | Signed link to the converted file (opens without a token), its record key, its name. |
| `format`, `width`, `height`, `frames`, `bytes`, `quality` | text, numbers | The output file. |
| `sourceFormat`, `sourceWidth`, `sourceHeight`, `sourceBytes`, `savedPercent` | text, numbers | The source and how much smaller the output is (negative when bigger). |
| `variant` | number | The width asked for in `widths`; `null` otherwise. |
| `note` | text | E.g. "only the first frame was kept", "could not reach 200 KB even at quality 20". |
| `imageIndex`, `sourceId`, `url`, `finalUrl`, `httpStatus`, `sources` | number, text | Which link the row belongs to (`sourceId` is a hash of the link, stable across restarts), the address after redirects, and where the link came from. |
| `billable`, `ms` | boolean, number | Whether the row is billed: it is saved first and charged right after (a charge that still fails after retries is counted in `OUTPUT.imagesNotCharged`); conversion time. |

The `OUTPUT` record holds the counts (`converted`, `outputs`, `errors`, `skipped`), `outputFormats`, `sourceBytes`, `outputBytes`, `savedPercent`, what was charged (`chargedImages`, `charged16mpBlocks`, `chargedLossless4mpBlocks`, and `imagesNotCharged`), `failures` and `zipUrl`. Files follow Apify data retention; copy them if you need permanent links.

### Pricing

| Event | When | Price |
|---|---|---|
| `image-converted` | One converted file saved, up to 16 megapixels | $0.002 |
| `extra-16mp` | Each further started 16 megapixels of a file (frames of an animation count) | $0.002 |
| `lossless-4mp` | Each started 4 megapixels of a lossless file: PNG output (also `same` that gives PNG) or lossless WebP (frames count) | $0.0025 |

**Paid Apify plans pay less.** Apify Store discounts apply automatically: `image-converted`: Bronze 5%, Silver 10%, Gold and higher 20% off; `extra-16mp`: Bronze 10%, Silver 20%, Gold and higher 30% off; `lossless-4mp`: Bronze 5%, Silver 5%, Gold and higher 5% off. The prices above are Free-plan prices; the Store card shows the lowest (Gold) price. The start event (`apify-actor-start`) has no discount.

Free: images that fail (download errors, HTTP errors, blocked addresses, unsupported or damaged files, too large for the run's memory, time-outs) and images not started because of the charge limit or the run timeout.

Apify also charges its start event, `apify-actor-start`: $0.00005 per GB of run memory, so $0.00005 per run at the default 1 GB.

Examples (a block is 16,000,000 pixels; every started block after the first is one `extra-16mp`):

- 1,000 product photos resized to 1920 px WebP (1920 × 1280 px each): 1,000 × $0.002 = **$2.00**.
- A 12-megapixel phone photo (4032 × 3024 px) at full size: **$0.002**.
- A 24-megapixel photo (6000 × 4000 px, 2 blocks): $0.002 + $0.002 = **$0.004**.
- A 48-megapixel photo (8064 × 6048 px = 48.8 MP, 4 blocks): $0.002 + 3 × $0.002 = **$0.008**. It needs 2 GB of memory: at the default 1 GB the limit is 33.5 MP, and a bigger photo gets a free `error` row.
- A responsive set of 3 widths (480, 960 and 1600 px): 3 × $0.002 = **$0.006** per image.
- A 2-megapixel graphic (1600 × 1250 px) as lossless WebP: $0.002 + $0.0025 = **$0.0045**.
- A 16-megapixel photo (4000 × 4000 px) as PNG or lossless WebP: $0.002 + 4 × $0.0025 = **$0.012**.
- A responsive set of 3 lossless WebP widths from a 3:2 photo of 3000 × 2000 pixels, so files of 480 × 320, 960 × 640 and 2500 × 1667 px: each file counts its own blocks, 3 × $0.002 + (1 + 1 + 2) × $0.0025 = **$0.016**.

### Limits

- Up to 10,000 images per run.
- Pixels per image depend on memory. At the default 1 GB: about 33 megapixels per image and per output (67 at 2 GB); about 16 megapixels for transparent images and their WebP/PNG outputs, and for lossless WebP; about 19 (opaque) or 15 (transparent) megapixels per AVIF output. Measured 2026-11-20 in a 1 GB container (`--memory 1g --memory-swap 1g`, the file server outside it), peak memory of all processes together at these limits: grainy photos (Gaussian grain σ 15) 626 MB as WebP, 351 MB as JPEG, 314 MB as PNG, 658 MB as AVIF, 816 MB as lossless WebP and 506 MB as transparent WebP; per-pixel random noise, the hardest content for the encoders, 894 MB as WebP (the highest), 829 MB as lossless WebP and 677 MB as AVIF; 4 such images at once 907 MB. Nothing ran out of memory, but noise-like images leave the least room: if one does, its row is a free `error` saying it needs more memory, and 2 GB doubles every limit above (the same noise image peaked at 903 MB of 2,048). Bigger images get a row with the reason and are free; give the run more memory or set `maxWidth`.
- WebP allows at most 16,383 px per side.
- PNG and lossless WebP are the slowest outputs: a 16 MP photo took 8.4 (PNG) and 32.6 (lossless WebP) CPU-seconds in our test, against 5.7 for WebP; hence the `lossless-4mp` price.
- Source files up to 500 MB (`maxFileSizeMb`). The run's disk (twice its memory) holds the source and the outputs of every image in progress, so fewer images run at once when files are big.
- JPEG allows at most 65,500 px per side.
- Measured on the platform at 1 GB (2026-11-19): three images (a 26-megapixel 3.2 MB JPEG, a small JPEG, a TIFF) in a 6-second run, the big one 46.8 % smaller as WebP; the same photo as AVIF in 3 widths in a 5-second run.
- Speed at Apify's CPU share (1/8 of a core per GB of memory), measured 2026-11-19 in Docker on a 2017 laptop CPU (Apify hosts may be faster, and some give a run more than its share): at the default 1 GB, real photos to WebP took 32 s (8 MP), 53 s (16 MP), 71 s (24 MP) and 97 s (33 MP); to AVIF 97 s (8 MP) and 133 s (16 MP, over the default `timeoutSecs` of 120 s). Twice the memory brings twice the CPU and about half the time: at 2 GB, 33 MP to WebP took 47 s, 24 MP to AVIF 96 s and 33 MP to AVIF 119 s. On the platform (2026-11-19, 1 GB) runs were much faster: five photos of 6–30 MP all converted to WebP, and the three up to 16 MP to AVIF, within the default limit. If images time out, give the run 2 GB for AVIF of photos over 8 MP and 4 GB over 24 MP; 4 GB for a KB target (`maxKb`, up to 9 encodes) or lossless WebP of photos, and for 67 MP photos (182 s at 2 GB); or raise `timeoutSecs`. Grainy or noisy images take 2–4 times longer. An image that runs out of time is free.
- Conversion uses one process per full CPU core of the run (at least one), and the memory limits above are shared by those processes. Give the run more memory for big batches of large images.

### Use it from your stack

You need an Apify account and token. No third-party API keys are needed.

- **API:**
  ```bash
  curl -X POST "https://api.apify.com/v2/acts/klarto~image-converter/run-sync-get-dataset-items?token=$APIFY_TOKEN" \
    -H 'Content-Type: application/json' -d '{"images":["https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg"],"format":"avif"}'
  ```
- **Python** (`apify-client` 3.x):
  ```python
  from apify_client import ApifyClient
  client = ApifyClient("<APIFY_TOKEN>")
  run = client.actor("klarto/image-converter").call(run_input={"images": ["https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg"], "maxWidth": 800})
  print(client.dataset(run.default_dataset_id).list_items().items)
  ```
- **n8n:** the Apify node, *Run an Actor* with `klarto/image-converter`, then *Get dataset items*.
- **Make / Zapier:** the Apify app with the same Actor.
- **MCP / AI agents:** `https://mcp.apify.com?tools=klarto/image-converter`.

### FAQ

**WebP or AVIF?** WebP works in all modern browsers and encodes fast. AVIF is usually smaller at the same quality but 2.5–3 times slower to encode (see Limits for the memory to give it) and not shown by some older software.

**Can it convert HEIC photos from iPhones?** No. HEIC is not supported; export the photos as JPEG first.

**Is GPS removed?** Yes by default (`stripMetadata`): EXIF, XMP and JPEG comments are not written to the output. Turn it off to keep EXIF (the orientation is set to upright).

**Why do PNG and lossless WebP cost more?** Lossless encoding takes several times the CPU of WebP, AVIF or JPEG, so each lossless file pays $0.0025 per started 4 megapixels on top of the image price. For photos use WebP or AVIF; PNG and lossless WebP suit logos, screenshots and graphics, which are small. AVIF output is always lossy here (the `lossless` option applies to WebP only), so it never pays lossless blocks.

**Why is the output bigger than the source?** An already well-compressed file, or PNG or lossless output, can grow. `savedPercent` shows it as a negative number; try WebP or a lower quality.

**Can I download everything at once?** Yes: `zipUrl` in the `OUTPUT` record downloads all converted files as one ZIP.

**Are private links supported?** Only links that anyone can open and that return the image file itself, not a web page around it.

### Fair use and licences

- Convert only images you own or may process.
- Libraries: Pillow (MIT-CMU) with libwebp (BSD-3-Clause), libavif (BSD-2-Clause), libjpeg-turbo (IJG/BSD) and zlib; httpx (BSD-3-Clause); Apify SDK (Apache-2.0).

### Ready-made examples

Saved inputs for common jobs: open one and run it as it is, or change the input first.

- [Convert images to WebP and compress them](https://apify.com/klarto/image-converter/examples/convert-images-to-webp)
- [Make responsive image sizes (srcset) in AVIF](https://apify.com/klarto/image-converter/examples/make-responsive-image-sizes)
- [Compress images to under 100 KB in bulk](https://apify.com/klarto/image-converter/examples/compress-images-to-100-kb)
- [Resize images in bulk to a maximum width](https://apify.com/klarto/image-converter/examples/resize-images-in-bulk)

### Related Actors

- [Bulk File Downloader](https://apify.com/klarto/bulk-file-downloader): download the originals first, then convert the `fileUrl` field.
- [Image Upscaler](https://apify.com/klarto/image-upscaler-cpu): enlarge small images 4×.
- [Website Screenshot & HTML to Image / PDF](https://apify.com/klarto/website-screenshot-pdf): capture pages as PNG or JPEG.

### Support

Open an issue on the Actor page. We aim to answer within a week.

# Actor input Schema

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

Direct links to images, one per line: JPEG, PNG, WebP, GIF, TIFF, BMP, AVIF or ICO. HEIC, SVG and RAW files are not supported. Repeated links are converted once. Only images you own or may process.

## `datasets` (type: `array`):

Optional: datasets whose rows hold image links, e.g. the output of a scraper or of Bulk File Downloader (field fileUrl). Picking a dataset gives this Actor read access to it (limited permissions). Through the API pass dataset IDs or 'username~name'.

## `imageFields` (type: `array`):

Fields of the dataset rows that hold the links: imageUrl, media.url, images.0, images.*.url (* = every item of a list). A field may hold one link, a list of links, or objects with a url, src or href key. Ignored without 'Datasets with image links'.

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

WebP is the usual choice for websites. AVIF is smaller still but slower to encode. JPEG has no transparency: transparent areas get the background color. 'Same as the source' keeps JPEG/PNG/WebP/AVIF and turns GIF, TIFF, BMP and ICO into PNG. PNG output adds $0.0025 per started 4 MP.

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

Encoder quality for WebP, AVIF and JPEG (1-100). 75-85 suits photos on the web. Ignored for PNG and lossless WebP.

## `maxKb` (type: `integer`):

Optional size target in KB (1 KB = 1,024 bytes): if a WebP (not lossless), AVIF or JPEG file is bigger, the quality is lowered, never below 20, until it fits. A quality of 20 or less is kept as it is. 0 = no target. The row's 'note' says when the target could not be reached.

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

Shrink wider images to this width, keeping the aspect ratio. 0 = no limit. Smaller images are never enlarged.

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

Shrink taller images to this height, keeping the aspect ratio. 0 = no limit. Smaller images are never enlarged.

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

How 'Max width' and 'Max height' apply. Cover crops the center to the box's shape; contain adds a background-colored border to reach the exact box size. Cover and contain need both values.

## `widths` (type: `array`):

Optional: make several sizes of each image, e.g. \[480, 960, 1600] for a srcset. Each size is one output file, charged as one image (plus its 16 MP and lossless blocks). Widths not smaller than the image are made once at the original size. Replaces 'Max width' and 'Max height'.

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

Remove EXIF, XMP and JPEG comments (camera, GPS location, dates) from the output. The photo is turned upright first, and the color profile is kept so colors stay right (CMYK is turned into sRGB with its own profile).

## `keepAnimation` (type: `boolean`):

Animated GIF, WebP, PNG or AVIF stay animated in WebP, AVIF or PNG (APNG) output, up to 300 frames within the memory budget. JPEG output, this option off, multi-page TIFF and MPO keep the first picture.

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

Encode WebP without any quality loss (bigger files; good for logos, screenshots and graphics). Used only with WebP output. Adds $0.0025 per started 4 MP of output (lossless-4mp).

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

Hex color for transparent areas in JPEG output and for the border in 'contain' mode, e.g. #ffffff or #000.

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

Stop after this many unique links (up to 10,000 per run).

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

Bigger source files are not downloaded and are free. Large images also need memory: at the default 1 GB about 33 megapixels per image (16 for transparent images and lossless WebP) and about 19 megapixels per AVIF output; give the run more memory for bigger ones.

## `timeoutSecs` (type: `integer`):

A conversion that takes longer is stopped and free. On Apify a run gets 1/8 of a CPU core per GB of memory; in our test at the default 1 GB a 16-megapixel photo took 53 s as WebP and 133 s as AVIF. Give the run 2-4 GB for AVIF, 'Max output size', lossless WebP or very large images (twice the memory, half the time), or raise this limit.

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

Downloads at once (at most 2 per site). Conversion uses one process per full CPU core of the run, at least one (measured on Apify: one core per 8 GB of memory).

## Actor input object example

```json
{
  "images": [
    "https://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
    "https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "imageFields": [
    "url"
  ],
  "format": "webp",
  "quality": 80,
  "maxKb": 0,
  "maxWidth": 0,
  "maxHeight": 0,
  "fit": "inside",
  "stripMetadata": true,
  "keepAnimation": true,
  "lossless": false,
  "background": "#ffffff",
  "maxImages": 1000,
  "maxFileSizeMb": 50,
  "timeoutSecs": 120,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

One row per output file: status, link to the converted file, format, size in pixels and bytes, saving versus the source; plus a row with the reason for each image that could not be converted.

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

Images converted, failed and skipped, bytes before and after, charges, failure reasons, and zipUrl (all converted files as one ZIP).

# 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://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
        "https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
    ],
    "imageFields": [
        "url"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("klarto/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://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
        "https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg",
        "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif",
    ],
    "imageFields": ["url"],
}

# Run the Actor and wait for it to finish
run = client.actor("klarto/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://images-assets.nasa.gov/image/as11-40-5903/as11-40-5903~orig.jpg",
    "https://images-assets.nasa.gov/image/as11-37-5505/as11-37-5505~small.jpg",
    "https://raw.githubusercontent.com/tesseract-ocr/test/main/testing/phototest.tif"
  ],
  "imageFields": [
    "url"
  ]
}' |
apify call klarto/image-converter --silent --output-dataset

```

## MCP server setup

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