# Image Compressor & Converter - Batch WebP, AVIF, JPEG, PNG (`rinveta/image-converter`) Actor

Bulk compress, resize and convert images to WebP, AVIF, JPEG or PNG. Get files one by one or as a ZIP. Pay only per image processed.

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

## Pricing

$1.50 / 1,000 images processed

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/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 Compressor & Converter – Batch WebP, AVIF, JPEG, PNG

**Bulk image compressor, resizer and converter.** Give it a list of image URLs (or a dataset, or your own key-value store) and get back smaller images in **WebP, AVIF, JPEG or PNG** – one file per image plus a single **ZIP**. Typical savings are **60–95 %** of the original file size with no visible quality loss, which means faster websites, lighter e-commerce catalogues and cheaper storage.

No browser, no scraping: the Actor only downloads the image URLs **you provide** and processes them with a fast native image library (libvips), a fast native image library.

### What can you do with it?

- **Convert images to WebP or AVIF in bulk** (JPEG to WebP, PNG to WebP, JPG to AVIF, WebP to JPEG…).
- **Compress images online without losing quality**: tune quality 1–100, lossless WebP/AVIF, 8-bit palette PNG.
- **Resize images in batch**: max width / max height, fit modes (inside, cover, contain, fill), never upscale.
- **Optimize e-commerce product photos**: feed the image column of a product dataset and get web-ready files.
- **Strip EXIF and GPS metadata** (default) and auto-rotate photos by EXIF orientation.
- **Download everything as a ZIP** or use the per-image URLs from the dataset in your pipeline or API call.

### Use cases

- **Image converter for e-commerce:** scrape a catalogue with any Actor, pass its dataset (`inputDatasetId` + `datasetUrlField`) to this Actor as the last step, and get web-ready WebP or AVIF files plus a ZIP.
- **Compress images for page speed:** shrink hero images and galleries to hit Core Web Vitals targets (LCP) without changing the visible quality.
- **JPG to WebP / PNG to WebP converter:** a list of URLs in, WebP out, with the saved bytes per image in the dataset.
- **Prepare images for AI and marketplaces:** resize to a maximum width or height, strip EXIF/GPS, convert transparency to a solid background for JPEG.
- **Clean up an archive:** recompress each file in its own format (`outputFormat: original`) and keep the original when it is already optimal.

### Input

| Field | Description |
|---|---|
| `imageUrls` | Direct URLs of the images (JPEG, PNG, WebP, AVIF, GIF, TIFF, HEIC, SVG). |
| `inputDatasetId` + `datasetUrlField` | Alternative: a dataset (e.g. from another Actor) whose items contain an image URL in the given field. |
| `inputKeyValueStoreId` + `keyPrefix` | Alternative: images you uploaded to a key-value store. |
| `outputFormat` | `webp` (default), `avif`, `jpeg`, `png` or `original` (recompress each image in its own format). |
| `quality` | 1–100, default 80. |
| `lossless`, `pngPalette`, `avifEffort` | Lossless WebP/AVIF, 8-bit PNG, AVIF CPU effort (default 2 = fast). |
| `maxWidth`, `maxHeight`, `fit`, `withoutEnlargement`, `backgroundColor` | Resizing and transparency fill (JPEG). |
| `autoRotate`, `keepMetadata` | EXIF handling. Metadata is removed by default. |
| `keepOriginalIfLarger` | If recompression would not make the file smaller, return the original untouched (default on). |
| `createZip`, `maxImages`, `maxImageSizeMB`, `concurrency` | ZIP output and safety limits. |

Example input:

```json
{
  "imageUrls": [
    { "url": "https://upload.wikimedia.org/wikipedia/commons/a/a7/Camponotus_flavomarginatus_ant.jpg" }
  ],
  "outputFormat": "webp",
  "quality": 80,
  "maxWidth": 1600
}
```

### Output

One dataset item per image:

```json
{
  "sourceUrl": "https://upload.wikimedia.org/wikipedia/commons/4/47/PNG_transparency_demonstration_1.png",
  "status": "converted",
  "outputKey": "0001-PNG_transparency_demonstration_1.webp",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/<STORE_ID>/records/0001-PNG_transparency_demonstration_1.webp",
  "originalFormat": "png",
  "outputFormat": "webp",
  "originalWidth": 800,
  "originalHeight": 600,
  "outputWidth": 800,
  "outputHeight": 600,
  "originalBytes": 224566,
  "outputBytes": 69056,
  "savedBytes": 155510,
  "savedPercent": 69.2
}
```

`status` is `converted`, `kept-original` (already optimal) or `failed` (with an `error` message, e.g. HTTP 404 – failed images are not charged). The key-value store also contains `images.zip` with all results and an `OUTPUT` record with totals (images, bytes before/after, percent saved, ZIP URL).

### Pricing

Pay per event: **$0.0015 per processed image** (event `image-processed`, $1.50 per 1,000 images). Failed downloads and skipped images are not charged. Platform usage is included in the event price.

### FAQ

**How do I convert JPG or PNG to WebP in bulk?** Add the image URLs to `imageUrls`, keep `outputFormat` on `webp` and run. Download the files one by one or as `images.zip`.

**How much will my images shrink?** Typically 60–95 % for photos at quality 80; the per-image `savedPercent` shows the exact result. If a file would not get smaller, the original is returned (`keepOriginalIfLarger`).

**Can I convert images that are on my computer?** Upload them to a key-value store in your account and use `inputKeyValueStoreId` with an optional `keyPrefix`.

**WebP or AVIF?** WebP is supported by every modern browser and is fast. AVIF is usually smaller but takes more CPU time (`avifEffort`, more memory).

**Are failed images charged?** No. Only successfully processed images ($0.0015 each).

**Is metadata removed?** Yes by default (EXIF, GPS). Set `keepMetadata` to keep it.

### Good to know

- Only the URLs you supply are downloaded; no crawling, no link following. Private/internal network addresses are refused.
- You are responsible for having the right to process the images you submit.
- Animated GIF/WebP: kept animated only when the output is WebP; other formats keep the first frame.
- For very large batches use `concurrency` 4–8 and at least 2 GB memory (AVIF: 4 GB).

### Run locally / integrate

```bash
npm install
echo '{"imageUrls":[{"url":"https://example.com/photo.jpg"}],"outputFormat":"webp"}' > storage/key_value_stores/default/INPUT.json
node src/main.js
```

Call it from the Apify API, the JavaScript/Python client, Make, Zapier, n8n or as a tool for AI agents (MCP).

### Related Actors

More Actors by Rinveta for data pipelines:

- [Dataset Merge, Dedupe & Transform](https://apify.com/rinveta/dataset-merge-dedupe): merge, deduplicate and convert datasets (CSV, JSON, XLSX).
- [PDF to Text & Markdown for RAG](https://apify.com/rinveta/pdf-to-markdown): per-page text, Markdown and page-cited chunks from PDFs.

**Related searches:** image converter, image compressor, compress images, optimize images, webp converter, avif converter, jpg to webp, png to webp, bulk image resize, batch image processing.

# Actor input Schema

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

Direct links to the images you want to compress or convert (JPEG, PNG, WebP, AVIF, GIF, TIFF, HEIC, SVG). Only the URLs you list here are downloaded.

## `inputDatasetId` (type: `string`):

ID or name of a dataset (for example the output of another Actor) whose items contain an image URL.

## `datasetUrlField` (type: `string`):

Name of the dataset field that contains the image URL.

## `inputKeyValueStoreId` (type: `string`):

ID or name of a key-value store holding your own image files. Every record whose key ends with an image extension is processed.

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

Only process records whose key starts with this prefix (key-value store input).

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

Target format. 'original' keeps each image in its own format (JPEG, PNG, WebP, AVIF) and only recompresses it.

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

Compression quality for WebP, AVIF, JPEG and palette PNG. 75-85 is visually lossless for most photos.

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

Encode WebP/AVIF without quality loss. Larger files.

## `avifEffort` (type: `integer`):

CPU effort for AVIF. 2 is fast with files ~10% larger than effort 4, which is about 8x slower.

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

Reduce PNG to a quantized palette using the quality setting. Much smaller files, slight color loss.

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

Resize so the width does not exceed this value. Leave empty for no limit.

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

Resize so the height does not exceed this value. Leave empty for no limit.

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

How the image fits in the max width/height box.

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

Do not enlarge images smaller than the target size.

## `backgroundColor` (type: `string`):

Used to fill transparency when converting to JPEG and for 'contain' resizing.

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

Apply the EXIF orientation so photos are upright after metadata is removed.

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

Off by default: metadata (including GPS position) is stripped, which also reduces size.

## `keepOriginalIfLarger` (type: `boolean`):

If recompression would not make an image smaller (and no resize was applied) the original file is returned unchanged.

## `createZip` (type: `boolean`):

Also save all results as images.zip in the key-value store.

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

Safety limit on the number of images processed in one run.

## `maxImageSizeMB` (type: `integer`):

Larger images are skipped with an error.

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

How many images are processed at the same time. Increase together with the run memory.

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

Maximum time to wait for each image download before it is reported as failed.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png"
    }
  ],
  "datasetUrlField": "url",
  "outputFormat": "webp",
  "quality": 80,
  "lossless": false,
  "avifEffort": 2,
  "pngPalette": false,
  "fit": "inside",
  "withoutEnlargement": true,
  "backgroundColor": "#ffffff",
  "autoRotate": true,
  "keepMetadata": false,
  "keepOriginalIfLarger": true,
  "createZip": true,
  "maxImages": 1000,
  "maxImageSizeMB": 30,
  "concurrency": 4,
  "downloadTimeoutSecs": 60
}
```

# Actor output Schema

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

One row per input image: status, converted file URL, size before/after, saved %.

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

ZIP archive with all converted images.

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

Totals: images, bytes before/after, percent saved, ZIP URL.

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

All converted image files in the key-value store.

# 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/7/70/Example.png"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("rinveta/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/7/70/Example.png" }] }

# Run the Actor and wait for it to finish
run = client.actor("rinveta/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/7/70/Example.png"
    }
  ]
}' |
apify call rinveta/image-converter --silent --output-dataset

```

## MCP server setup

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