# Image Converter Pro: Target Size, Crop, Dataset Input (`ucchiii/image-converter-pro`) Actor

Convert AVIF, JPG, PNG, WebP, GIF, BMP or TIFF to JPG, PNG, WebP or AVIF. Hit a target file size in KB, crop to fill or pad to an exact size, grayscale, ZIP. Reads URLs, dataset fields or key-value store images. Empty input = free demo.

- **URL**: https://apify.com/ucchiii/image-converter-pro.md
- **Developed by:** [Actor Factory](https://apify.com/ucchiii) (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 $0.91 / 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 for AVIF, JPG, PNG, WebP, GIF, BMP and TIFF: hit a target file size in KB, crop or pad to an exact size, and read images from URLs, datasets or key-value stores — $2 per 1,000 images**

Give it image links, a dataset from a scraper run or a key-value store full of images, pick the output format and press Start. Every image is converted, saved in the run's storage with a download link, and listed as one row with the size before and after, the final quality and whether your target size was reached. One flat price per image, whatever options you use.

**Basic or Pro?** If you only need to convert JPG, PNG, WebP, GIF, BMP or TIFF from URLs with an optional maximum width and height, [Image Converter](https://apify.com/ucchiii/image-converter) does that for less. This Pro version adds AVIF input, a target file size, cover / contain resize modes, grayscale, ZIP output and dataset / key-value store input.

### What you get

| sourceUrl | status | format | sourceBytes | bytes | quality | targetKb | achievedKb | scaled | width | height | outputUrl |
|---|---|---|---|---|---|---|---|---|---|---|---|
| https://example.com/IMG_0412.PNG | ok | jpg | 2,913,201 | 199,870 | 71 | 200 | 195.2 | false | 4032 | 3024 | https://api.apify.com/v2/key-value-stores/.../records/0001-IMG_0412.jpg |
| https://example.com/banner.png | ok | jpg | 1,204,330 | 98,112 | 30 | 100 | 95.8 | true | 1710 | 900 | https://api.apify.com/v2/key-value-stores/.../records/0002-banner.jpg |
| https://example.com/missing.png | failed | | | | | | | | | | *(error: The server answered HTTP 404 ...)* |

**Try it free:** leave all image inputs empty and press **Start** — built-in sample images (a PNG with transparency and a JPG photo) are converted with the options you set. Not charged; rows carry `_demo: true`.

### How to use

1. **Images** — any mix of: **Image URLs** (one per line), a **Dataset with image URLs** plus the **URL field** that holds them, and a **Key-value store with images** (optionally **Only keys starting with**).
2. **Convert to**: WebP (default), JPG, PNG or AVIF.
3. Optional: **Target file size (KB)**, **Width** / **Height** with a **Resize mode**, **Quality**, **Grayscale**, **Auto-rotate**, **Remove metadata**, **Also create a ZIP**.

```json
{
  "imageUrls": ["https://example.com/IMG_0412.PNG", "https://example.com/banner.png"],
  "outputFormat": "jpg",
  "targetKb": 200,
  "width": 1600,
  "height": 1600,
  "fit": "inside",
  "zipOutput": true
}
```

### AVIF input

AVIF files are read directly and can be saved as JPG, PNG, WebP or AVIF. The photo is turned upright and the color profile is kept so colors look the same.

### Target size

Set **Target file size (KB)** for JPG, WebP or AVIF output and every file is made at most that size (1 KB = 1,024 bytes):

1. The highest quality from **Quality** (default 85) down to **Minimum quality** (default 30) that fits is found by binary search.
2. If even the minimum quality is too big, the image is shrunk step by step (keeping the aspect ratio) and the search runs again.
3. If it still cannot fit (images are not shrunk below 16 pixels on the short side), the smallest result is saved with a `note` and `targetReached: false`. It still counts as a converted image.

Each row shows `targetKb`, `achievedKb`, the final `quality` and `scaled` (true when the image had to be shrunk). PNG is lossless, so a target size needs JPG, WebP or AVIF.

### Resize modes

Set **Width** and/or **Height** and choose a **Resize mode**:

- **inside** (default) — fit inside the box and keep the aspect ratio: 4000×3000 with width 1200 becomes 1200×900. Either side alone is fine.
- **cover** — fill the box exactly and crop the overflow from the centre: 4000×3000 with 800×800 becomes 800×800.
- **contain** — fit inside the box and fill the rest with the **Background color**: 4000×3000 with 800×800 becomes 800×800 with bars top and bottom. Also accepted as `pad`.

**Allow enlarging small images** is off by default, so images are only made smaller: in cover mode a small image is cropped to the box's aspect ratio without enlarging, in contain mode it is centred on the full-size box. Turn it on to scale small images up to the box.

### Inputs (URLs / dataset / key-value store)

- **Image URLs** — public http(s) links. Duplicates are converted once.
- **Dataset** — the ID of any dataset, such as a scraper run's `defaultDatasetId`. **URL field** takes dots for nested fields (`product.image`, `images.0`) and reads every URL in a list field (`imageUrls`).
- **Key-value store** — the ID of a store that already holds image files, for example from a downloader run. Every binary record is converted (filter with **Only keys starting with**); JSON and text records such as `INPUT` are skipped. Rows carry `sourceKey` instead of `sourceUrl`.

All three can be combined in one run; the 1,000-image limit applies to the total.

### Output fields

- `source` (`url`, `dataset`, `keyValueStore` or `demo`), `sourceUrl` or `sourceKey`, `status` (`ok` or `failed`), `error` (the reason when it failed — failed images are free)
- `fileName`, `outputUrl` — the converted file in the run's key-value store
- `inputFormat`, `format`, `width`, `height`, `originalWidth`, `originalHeight`, `fit`
- `sourceBytes`, `bytes`, `sizeChangePercent` (negative = smaller), `quality`
- `targetKb`, `achievedKb`, `targetReached`, `scaled`, `note`, `animated`, `inZip`

A **STATS** record sums up images converted, failed and charged, the options used and the ZIP link (`zipUrl`). With **Also create a ZIP**, all converted files are also in `images.zip`. Download the rows as CSV, Excel or JSON from the run page.

### Other options

- **Auto-rotate from EXIF** (on): portrait photos stay upright.
- **Remove metadata** (on): EXIF data such as camera details, date and GPS location is not copied into the output. Turn it off to keep EXIF. The RGB color profile is kept either way.
- **Grayscale**: black-and-white output (transparency is kept in PNG, WebP and AVIF).
- **Animated GIFs and multi-page TIFFs**: the first frame or page is converted (`animated: true`).
- **Transparency** is kept in PNG, WebP and AVIF; JPG has none, so transparent areas get the background color.

### Pricing

Pay per event: **$0.0013 per converted image ($1.30 per 1,000 images)**, the same for any file size and any options, including target size, crop and ZIP. Failed downloads, unreadable or oversized images and the demo are free.
Store discounts apply automatically: BRONZE −10%, SILVER −20%, GOLD −30%.
On the Apify Free plan, the $5 of monthly platform credit covers about 2,500 images a month.

### Limits (cannot be raised by input)

- 1,000 images per run (URLs + dataset + key-value store); 25 MB per input file; 50 megapixels per image (protection against "decompression bomb" files)
- WebP allows at most 16,383 pixels per side — set a width or height for bigger images
- ZIP: up to 300 MB of files; images beyond that are still saved and linked, with `inZip: false`
- Public images only (no login); links to internal network addresses are blocked, also after redirects
- Set a maximum charge per run to cap spend: the run stops cleanly when it is reached and keeps the images converted so far

### Use it from the API, Make, n8n or an AI agent (MCP)

Run it and get the rows back in one HTTP call (replace `<YOUR_TOKEN>` with your Apify API token):

```bash
curl -X POST "https://api.apify.com/v2/acts/ucchiii~image-converter-pro/run-sync-get-dataset-items?token=<YOUR_TOKEN>" \
  -H "Content-Type: application/json" \
  -d '{"imageUrls": ["https://example.com/IMG_0412.PNG"], "outputFormat": "jpg", "targetKb": 200}'
```

Each row's `outputUrl` is a direct download link to the converted file.

- **Make, n8n, Zapier:** use the Apify app / node, pick this Actor and pass the same JSON input.
- **AI agents (Claude, Cursor and other MCP clients):** add `https://mcp.apify.com?tools=ucchiii/image-converter-pro` to your MCP settings.

### FAQ

**Does the target size always hold?** When it is reachable, yes: the saved file is measured, never estimated, so `bytes` is at most `targetKb` × 1,024. When it is not reachable, you get the smallest result and a note instead of a failure.

**Why did my image get smaller in pixels?** Only when the target size could not be reached at the minimum quality (`scaled: true`). Lower **Minimum quality** to keep more pixels, or raise it to keep more quality.

**Which format should I pick?** WebP for websites (small, supported by all current browsers), JPG for maximum compatibility for photos, PNG for lossless graphics and screenshots, AVIF for the smallest files where it is supported.

**Can I convert SVG or RAW camera files?** Not at the moment. Supported inputs are JPG, PNG, WebP, GIF, BMP, TIFF and AVIF. iPhone HEIC photos are not supported.

**How long are the files kept?** As long as the run's storage is kept under your Apify plan's data retention. Download them (or the ZIP) or copy them to your own storage if you need them longer.

If this Actor saved you time, a rating on the Store helps others find it.

### More tools from the same developer

- [Image Converter](https://apify.com/ucchiii/image-converter) — convert images between JPG, PNG, WebP and AVIF, with optional resize
- [Images to PDF](https://apify.com/ucchiii/images-to-pdf) — combine image URLs into one PDF or one PDF per image: A4, Letter or fit, margins
- [PDF to Image](https://apify.com/ucchiii/pdf-to-image) — PDF pages to PNG, JPG or WebP images in bulk: up to 300 DPI, page ranges, one public link per page
- [Tesseract OCR](https://apify.com/ucchiii/ocr-image-text) — OCR for image URLs and scanned PDFs with built-in Tesseract: text, confidence and line boxes in 8 languages
- [Website Image Extractor](https://apify.com/ucchiii/website-image-extractor) — every image on your pages with alt text, srcset, size and type (HEAD only), flagging missing alt and oversized images

# Actor input Schema

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

Public http(s) links to JPG, PNG, WebP, GIF, BMP, TIFF or AVIF images, one per line. Up to 1,000 images per run in total (URLs + dataset + key-value store), 25 MB and 50 megapixels each. Leave all image inputs empty for a free demo on built-in sample images.

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

Optional. ID of a dataset (for example a scraper run's 'defaultDatasetId') whose items contain image URLs. They are added after the list above.

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

Field of each dataset item that holds the image URL. Use dots for nested fields, e.g. 'product.image' or 'images.0'. A list of URLs (e.g. 'imageUrls') is read in full. Default 'url'.

## `keyValueStoreId` (type: `string`):

Optional. ID of a key-value store that already holds image files (for example from a downloader run). Every binary record is converted; JSON and text records such as INPUT are skipped.

## `keyPrefix` (type: `string`):

Optional. Convert only key-value store records whose key starts with this text, e.g. 'photo-'.

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

Output format. Transparent areas become the background color in JPG.

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

1-100. Default 85. Lower = smaller files. With a target size this is the highest quality tried. PNG is always lossless and ignores this.

## `targetKb` (type: `integer`):

Optional, for JPG, WebP and AVIF. Each file is made at most this many kilobytes (1 KB = 1,024 bytes): the highest quality that fits is searched, and if even the minimum quality is too big the image is shrunk in steps. If it still cannot fit, the smallest result is saved with a note.

## `minQuality` (type: `integer`):

With a target size, quality is not lowered below this; the image is shrunk instead. Default 30.

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

Optional. Box width. With 'inside' it is a maximum; with 'cover' and 'contain' it is the exact output width.

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

Optional. Box height. With 'inside' it is a maximum; with 'cover' and 'contain' it is the exact output height.

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

How width and height are used. Cover and contain need both width and height.

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

Off (default): images are only made smaller. On: smaller images are enlarged to the box.

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

Hex color for transparent areas in JPG and for the padding in 'contain' mode. Default #FFFFFF (white).

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

Convert images to black and white.

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

Turn photos upright using the camera's orientation tag (EXIF). Default on.

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

Default on: EXIF data such as camera details, date and GPS location is not copied into the output. Off: EXIF is kept. The RGB color profile is always kept so colors look the same.

## `zipOutput` (type: `boolean`):

Also put all converted files into one ZIP (key 'images.zip'; its link is in the STATS record and the run's output tab). Up to 300 MB in total. No extra charge.

## Actor input object example

```json
{
  "imageUrls": [
    "https://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/hopper.png"
  ],
  "urlField": "url",
  "outputFormat": "webp",
  "quality": 85,
  "minQuality": 30,
  "fit": "inside",
  "allowUpscale": false,
  "background": "#FFFFFF",
  "grayscale": false,
  "autoRotate": true,
  "stripMetadata": true,
  "zipOutput": false
}
```

# Actor output Schema

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

One row per image: download link, formats, width and height, bytes before and after, final quality, target size reached or not, or the reason it failed.

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

The key-value store that holds the converted image files (and images.zip when 'Also create a ZIP' is on).

## `zip` (type: `string`):

The ZIP of all converted files. Only exists when 'Also create a ZIP' is on.

## `stats` (type: `string`):

Record STATS: images converted, failed and charged, the options used, the ZIP link and whether the run stopped early.

# 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://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/hopper.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ucchiii/image-converter-pro").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://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/hopper.png"] }

# Run the Actor and wait for it to finish
run = client.actor("ucchiii/image-converter-pro").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://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/hopper.png"
  ]
}' |
apify call ucchiii/image-converter-pro --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,ucchiii/image-converter-pro"
        }
    }
}
```

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/vn11a0U67VlU8MSrF/builds/139H587ciutQBfgop/openapi.json
