# Bulk Image Compressor & Converter: WebP, AVIF (`conserving_celerytop/image-converter-compressor`) Actor

$0.003 per image. Convert, compress and resize images in bulk to WebP, AVIF, JPEG or PNG. Links, uploads or base64 in. Set quality or a target size in KB, a maximum width and height, and strip metadata. Returns file links and percent saved. Failed images are free.

- **URL**: https://apify.com/conserving\_celerytop/image-converter-compressor.md
- **Developed by:** [Don Mangu](https://apify.com/conserving_celerytop) (community)
- **Categories:** Developer tools, Automation, E-commerce
- **Stats:** 2 total users, 2 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.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 and Compressor

Image Converter and Compressor turns your images into smaller WebP, AVIF, JPEG or PNG files in bulk. Give it image links, uploaded files or base64 data, pick a format and a quality, and get back a link to each new file with its size before and after and the percent saved. You can also set a target size in KB, a maximum width and height, and remove camera metadata such as GPS location. Failed images are free.

### What does Image Converter and Compressor do?

- **Converts** JPEG, PNG, WebP, AVIF, GIF, TIFF, BMP and ICO files to **WebP, AVIF, JPEG or PNG**, or compresses them in the same format.
- **Compresses** with a quality setting from 1 to 100, or with a **target size**: quality is lowered until each file fits, and the image is made smaller only when quality alone cannot get there.
- **Resizes** to a maximum width and height, keeping the aspect ratio. Small images are never enlarged.
- **Strips metadata** (EXIF and XMP: camera, date, GPS) by default, while keeping the color profile so colors look the same.
- **Rotates photos upright** from the camera orientation tag.
- **Keeps transparency** in WebP, AVIF and PNG, and fills it with a color you choose for JPEG.
- **Keeps animations** from GIF, WebP, PNG and AVIF when the output is WebP, AVIF or PNG.
- Returns a **dataset row per image** with the file link, format, width, height, bytes before and after, percent saved and the quality used, plus an optional base64 copy for tools that cannot open links.

### Why convert images to WebP or AVIF?

Smaller images load faster, which helps page speed scores, mobile users and hosting bills. WebP files are often 25% to 80% smaller than JPEG or PNG at similar visual quality, and AVIF is often smaller again. Online shops, blogs, marketing teams and developers use this Actor to prepare product photos, banners and screenshots for the web, to meet upload limits of marketplaces and forms, and to clean location data out of photos before sharing them.

### How to convert and compress images in bulk

1. Add your images: paste direct image links in **Image URLs**, upload files in **Upload images**, or paste base64 strings or data URIs in **Image data (base64)**.
2. Choose the **Output format**. WebP is a safe default for websites.
3. Set **Quality** (80 is a good start), or set **Target size** in KB if you need files under a limit.
4. Optionally set **Maximum width** and **Maximum height** to shrink large photos.
5. Click **Start**. When the run finishes, open the **Converted images** table and click a link to download each file, or read the dataset through the API.

### How much does it cost to compress images?

This Actor uses pay-per-event pricing. You pay for each image that was converted and saved, and nothing for images that fail.

| Plan | Price per image |
| --- | --- |
| Free | $0.003 |
| Bronze | $0.0025 |
| Silver, Gold, Platinum, Diamond | $0.002 |

One image is counted per started 16 megapixels (4096 x 4096), so almost every photo counts once. A very large 50 MP scan counts as 3.

**Example:** converting 1,000 product photos to WebP on the Free plan costs 1,000 x $0.003 = **$3.00**, plus the small Actor start fee set by Apify. On a Silver plan the same run costs $2.00. You can set a maximum cost per run in the run options, and the Actor stops cleanly when it is reached.

### Input example

```json
{
    "imageUrls": ["https://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/flower.jpg"],
    "outputFormat": "webp",
    "quality": 80,
    "maxWidth": 1600,
    "targetSizeKb": 200
}
```

### Output example

```json
{
    "inputIndex": 1,
    "imageUrl": "https://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/flower.jpg",
    "status": "ok",
    "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/converted-0001-flower.webp",
    "outputFormat": "webp",
    "outputWidth": 480,
    "outputHeight": 360,
    "inputSizeBytes": 32764,
    "outputSizeBytes": 18620,
    "savedPercent": 43.2,
    "qualityUsed": 80,
    "targetMet": true,
    "billedImages": 1,
    "error": null
}
```

The files themselves are in the run's key-value store under keys that start with `converted-`. A `STATS` record sums up the run: images done, statuses, bytes before and after, and bytes saved.

### Tips

- For photos on websites, WebP at quality 75 to 85 is a good balance. AVIF gives smaller files for the same look but takes longer to encode.
- PNG output is lossless, so quality does not change it. Use WebP with **Lossless WebP and AVIF** for graphics and screenshots that need exact pixels at a smaller size.
- If a new file comes out larger than the source, the row says so. This happens when a small, already compressed JPEG is saved at high quality. Lower the quality or pick WebP.
- Base64 output is limited to files up to 2 MB; larger files are always available by link.

### Related tools

Pair this Actor with our AI Image Upscaler when you need larger images first, or with our Image OCR Actor to read text from the converted files.

### FAQ

**Is it legal to use this Actor?** It only downloads the image links you give it and processes files you upload. Convert only images you own or have the right to use. The Actor reads each host's robots.txt, uses a clear user agent with a contact address, and does not get around logins, blocks or rate limits.

**Which formats can I upload?** JPEG, PNG, WebP, AVIF, GIF, TIFF, BMP and ICO. SVG, PDF and HEIC are not supported yet.

**Are my images stored?** The new files stay in your own run storage, which follows your Apify data retention. Nothing is sent anywhere else.

**What are the limits?** Up to 10,000 images per run, 50 MB per file and 100 megapixels per image. Animations up to 300 frames.

**Why did an image fail?** The `status` and `error` fields explain it, for example `not_found`, `blocked`, `robots_disallowed` or `corrupt_image`. Failed images are not billed. If you think the Actor got it wrong, open an issue with the link and we will look at it.

# Actor input Schema

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

Enter direct links to image files, one per line: JPEG, PNG, WebP, AVIF, GIF, TIFF or BMP. Use your own photos, product shots, banners or screenshots.

## `imageUploads` (type: `array`):

Upload image files from your computer. Each file is stored in a key-value store you choose and read from its link.

## `imageBase64` (type: `array`):

Paste images as base64 strings or data URIs (data:image/png;base64,...), one per line. Handy from Make, Zapier, n8n or your own code. Up to about 10 MB each.

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

Choose the format of the new files. WebP and AVIF give the smallest files for the web; JPEG works everywhere; PNG is lossless and keeps transparency.

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

Set the compression quality for WebP, AVIF and JPEG, from 1 (smallest file) to 100 (best image). 75 to 85 suits most web images.

## `targetSizeKb` (type: `integer`):

Enter the largest file size you want per image. Quality is lowered step by step until the file fits, then the image is made smaller if needed. WebP, AVIF and JPEG only.

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

Shrink wider images to this width, keeping the aspect ratio. Smaller images keep their size.

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

Shrink taller images to this height, keeping the aspect ratio. Smaller images keep their size.

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

Keep EXIF and XMP data (camera, date, GPS, copyright) in the new files. Off gives smaller files and removes location data. The color profile is always kept.

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

Turn photos upright using the camera's orientation tag, so they display the same everywhere.

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

Save WebP without any quality loss (AVIF at top quality). Files are larger than lossy ones but usually smaller than PNG.

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

Enter the color that fills transparent areas when saving JPEG, as a hex code.

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

Keep all frames of animated GIF, WebP, PNG and AVIF files when the output is WebP, AVIF or PNG. JPEG output always takes the first frame.

## `returnBase64` (type: `boolean`):

Add each new file as a data URI in the dataset row (files up to 2 MB), for tools that cannot open links.

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

Convert at most this many images per run.

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

Download source files up to this size.

## Actor input object example

```json
{
  "imageUrls": [
    "https://raw.githubusercontent.com/python-pillow/Pillow/main/Tests/images/flower.jpg"
  ],
  "imageBase64": [
    "data:image/png;base64,iVBORw0KGgo..."
  ],
  "outputFormat": "webp",
  "quality": 80,
  "keepMetadata": false,
  "autoRotate": true,
  "lossless": false,
  "backgroundColor": "#ffffff",
  "keepAnimation": true,
  "returnBase64": false,
  "maxImages": 1000,
  "maxFileSizeMb": 25
}
```

# Actor output Schema

## `overview` (type: `string`):

outputUrl, status, imageUrl, formats, bytes before and after, savedPercent, width, height, qualityUsed and error.

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

All new image files (keys start with converted-).

## `errors` (type: `string`):

Images that could not be converted and why. Not billed.

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

JSON with images planned and done, statuses, images billed, bytes in and out, bytes saved, seconds and peak memory.

# 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/flower.jpg"
    ],
    "outputFormat": "webp",
    "quality": 80
};

// Run the Actor and wait for it to finish
const run = await client.actor("conserving_celerytop/image-converter-compressor").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/flower.jpg"],
    "outputFormat": "webp",
    "quality": 80,
}

# Run the Actor and wait for it to finish
run = client.actor("conserving_celerytop/image-converter-compressor").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/flower.jpg"
  ],
  "outputFormat": "webp",
  "quality": 80
}' |
apify call conserving_celerytop/image-converter-compressor --silent --output-dataset

```

## MCP server setup

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

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/G6ngaOhlNEgKPFtf0/builds/D20PuJK2fWskMXiFm/openapi.json
