# Bulk Image Compressor & WebP / AVIF Converter (`chivalrous_skyline_vtd/bulk-image-optimizer`) Actor

Compress, resize and convert images by URL to WebP, AVIF, JPEG or PNG. Bulk up to 2,000 images, keeps transparency, strips metadata, reports the bytes saved per file.

- **URL**: https://apify.com/chivalrous_skyline_vtd/bulk-image-optimizer.md
- **Developed by:** [HexaX](https://apify.com/chivalrous_skyline_vtd) (community)
- **Categories:** Developer tools, Other
- **Security:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$4.00 / 1,000 image optimizeds

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

## Bulk Image Compressor & WebP / AVIF Converter

Compress, resize and convert images in bulk: give it image URLs, get **smaller WebP, AVIF, JPEG or PNG files** and a per-file report of the bytes saved.

### What you get

- Output as **WebP, AVIF, JPEG or PNG**, lossy or lossless.
- Optional resize to a maximum width and/or height (aspect ratio kept, never enlarged).
- **Transparency is kept** for WebP, AVIF and PNG; for JPEG it is filled with a background color you choose.
- Metadata (EXIF including GPS, embedded AI prompts) is dropped by default; photo rotation is applied to the pixels first, so nothing ends up sideways.
- A report row per image: size before and after, percent saved, dimensions before and after, and a link to the file.
- A result is only delivered, and only charged, when it is **actually smaller** than the original.

### Use cases

- Shrink image sets for websites, shops and galleries (Core Web Vitals, page weight).
- Convert PNG / JPEG libraries to WebP or AVIF.
- Make fixed-size previews and thumbnails of a long list of URLs.
- Batch-reduce AI-generated PNGs, which are often very large, before delivery.

### Quick start

Keep the example URLs and press Start. Optimized files appear in the run's **Key-value store**; the dataset lists the savings.

### Input

```json
{
  "imageUrls": ["https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg"],
  "outputFormat": "webp",
  "quality": 80,
  "maxWidth": 1600
}
```

| Field | Default | Notes |
|---|---|---|
| `imageUrls` | (required) | Up to 2,000 direct links. JPEG, PNG, WebP, BMP and still GIF. Animated files are skipped. |
| `outputFormat` | `webp` | `webp`, `avif`, `jpeg` or `png`. |
| `quality` | `80` | 1-100, for lossy WebP / AVIF / JPEG. |
| `lossless` | `false` | Lossless WebP / AVIF. Best for screenshots and flat-color illustrations. |
| `maxWidth` / `maxHeight` | `0` | 0 = no limit. |
| `keepMetadata` | `false` | Keep EXIF and the color profile. |
| `backgroundColor` | `#ffffff` | Fill for transparent areas when writing JPEG. |
| `maxImageSizeMb` | `30` | Larger source files are skipped with an error. |
| `maxConcurrency` | `4` | Parallel downloads. |

### Output

```json
{
  "url": "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
  "status": "optimized",
  "source_format": "jpeg",
  "output_format": "webp",
  "bytes_before": 161713,
  "bytes_after": 118522,
  "saved_percent": 26.7,
  "width_before": 640, "height_before": 480,
  "width_after": 640, "height_after": 480,
  "optimized_file_key": "00002-DSCN0010.webp",
  "optimized_file_url": "https://api.apify.com/v2/key-value-stores/<id>/records/00002-DSCN0010.webp"
}
```

`status` is `optimized`, `not_smaller` (the result would not be smaller: no file written, not charged) or `error`.

### Limits

- Inputs over 100 megapixels, animated images and non-image files are reported as errors.
- AVIF encoding is slower than WebP; large batches take longer.
- Each site's `robots.txt` is checked before downloading. Use it on images you are allowed to process.

### Pricing

Pay per event: you are charged once per image that came out smaller. Failed downloads and `not_smaller` results are free.

### Related Actors

- **Image Metadata Remover**: strip EXIF, GPS and AI prompts without re-encoding.
- **Duplicate & Similar Image Finder**: remove repeated images before you compress the rest.
- **Stable Diffusion Prompt Extractor**: read the prompt and settings embedded in AI images.

# Actor input Schema

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

Direct links to JPEG, PNG, WebP, BMP or still-GIF files, up to 2,000 per run. Animated images are skipped. Only images you are allowed to download and convert. Each site's robots.txt is checked first.

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

WebP is the safe default. AVIF is smaller but slower to encode.

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

Lossy quality for WebP, AVIF and JPEG. 75-85 is visually near-identical for most images. Ignored for PNG and for lossless mode.

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

Lossless WebP or AVIF (no quality loss, bigger files). Good for screenshots, line art and anime-style illustrations with flat colors.

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

Shrink images wider than this, keeping the aspect ratio. 0 = no limit. Images are never enlarged.

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

Shrink images taller than this, keeping the aspect ratio. 0 = no limit.

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

Keep EXIF and the color profile. Off by default: EXIF (including GPS) and embedded AI prompts are dropped. Photo rotation is always applied to the pixels first.

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

JPEG has no transparency, so transparent areas are filled with this color.

## `maxImageSizeMb` (type: `integer`):

Larger source files are skipped with an error.

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

Lower this if a site rate-limits you.

## Actor input object example

```json
{
  "imageUrls": [
    "https://raw.githubusercontent.com/d3x-at/sd-parsers/master/tests/resources/parsers/AUTOMATIC1111/automatic1111_cropped.png",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg"
  ],
  "outputFormat": "webp",
  "quality": 80,
  "lossless": false,
  "maxWidth": 0,
  "maxHeight": 0,
  "keepMetadata": false,
  "backgroundColor": "#ffffff",
  "maxImageSizeMb": 30,
  "maxConcurrency": 4
}
```

# Actor output Schema

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

Results in the run's default dataset.

# 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/d3x-at/sd-parsers/master/tests/resources/parsers/AUTOMATIC1111/automatic1111_cropped.png",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("chivalrous_skyline_vtd/bulk-image-optimizer").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/d3x-at/sd-parsers/master/tests/resources/parsers/AUTOMATIC1111/automatic1111_cropped.png",
        "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("chivalrous_skyline_vtd/bulk-image-optimizer").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/d3x-at/sd-parsers/master/tests/resources/parsers/AUTOMATIC1111/automatic1111_cropped.png",
    "https://raw.githubusercontent.com/ianare/exif-samples/master/jpg/gps/DSCN0010.jpg"
  ]
}' |
apify call chivalrous_skyline_vtd/bulk-image-optimizer --silent --output-dataset

```

## MCP server setup

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

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/BBNLelc8wuW7j5TYB/builds/4W1hVSAU0oSnCTq9i/openapi.json
