# Bulk Image Optimizer: Resize, WebP and AVIF (`clearcheck/image-optimizer`) Actor

Bulk image optimizer: download image URLs, resize, convert to WebP, AVIF, JPEG or PNG, compress and strip EXIF/GPS metadata. Returns links and bytes saved.

- **URL**: https://apify.com/clearcheck/image-optimizer.md
- **Developed by:** [ClearCheck Tools](https://apify.com/clearcheck) (community)
- **Categories:** Developer tools, Automation, E-commerce
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $3.00 / 1,000 image optimiseds

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 Optimizer: Resize, WebP and AVIF

Shrink your images in bulk. Give it a list of **image URLs**; it downloads each one, resizes it, converts it to **WebP, AVIF, JPEG or PNG**, compresses it, strips private metadata (EXIF, GPS) and hands back a **download link** with the bytes saved. Typical result: **60-90% smaller files** for photos, with no visible loss.

All the work is done locally by libvips (through `sharp`). Images are not sent to any third-party service and nothing is kept after the run storage expires.

### What it does

- **Convert**: WebP (default), AVIF, JPEG, PNG, or keep each image's own format (`original`).
- **Resize**: `maxWidth` / `maxHeight`, with `inside`, `cover`, `contain` or `fill` modes. Images are never enlarged.
- **Compress**: one `quality` setting (1-100). PNG supports palette quantisation below 100.
- **Strip metadata**: removes EXIF, GPS position and camera data by default (the orientation is applied first, so photos are never rotated wrongly). Can be turned off.
- **Transparency**: kept for WebP/AVIF/PNG; flattened on white when converting to JPEG.
- **Animated GIF to animated WebP** (frames are kept).
- Accepts JPEG, PNG, WebP, AVIF, GIF, TIFF and SVG input.

### Input

```json
{
    "imageUrls": ["https://example.com/photo1.jpg", "https://example.com/banner.png"],
    "format": "webp",
    "quality": 80,
    "maxWidth": 1600,
    "maxHeight": 0,
    "fit": "inside",
    "stripMetadata": true
}
```

Up to 2,000 images per run, 30 MB and 100 megapixels each. Duplicate URLs are ignored.

### Output

One dataset item per image, and the optimised files in the run's **key-value store** (`img-0001-xxxxxxxx.webp`...).

```json
{
    "url": "https://picsum.photos/id/10/2400/1600.jpg",
    "status": "ok",
    "outputUrl": "https://api.apify.com/v2/key-value-stores/.../records/img-0001-7f8ac15a.webp?signature=...",
    "sourceFormat": "jpeg", "sourceWidth": 2400, "sourceHeight": 1600,
    "outputFormat": "webp", "outputWidth": 1200, "outputHeight": 800,
    "originalBytes": 505464, "outputBytes": 109736, "savedBytes": 395728, "savedPercent": 78.3,
    "sourceHadExif": false, "animated": false, "keptOriginal": false, "error": null
}
```

`outputUrl` is a signed link: anyone who has it can download the file, even though your storage is otherwise private. Failed images appear with `status: "failed"` and an `error` (`http_404`, `not_a_supported_image`, `file_too_large`, `timeout`, `private_address_blocked`...) and are **not charged**.

A run summary (images optimised, failed, total bytes before/after, percentage saved) is stored under the `SUMMARY` key.

### Use cases

- **Website speed**: convert a product or blog image library to WebP or AVIF and serve smaller files.
- **E-commerce catalogues**: resize thousands of supplier images to one standard width.
- **Privacy**: strip GPS and EXIF metadata from photos before you publish them.
- **Pipelines**: normalise images scraped by other Actors before storing or sending them on.

### Pricing

Pay per event. You can cap spending with the maximum cost per run.

| Event | Price | When it is charged |
|---|---|---|
| Image processed | $0.003 per image ($3 per 1,000) | Once per image downloaded and successfully processed |
| Actor start | $0.00005 per run | Flat fee per run start |

Not charged: failed downloads, unsupported files, duplicates and invalid URLs. The Actor stops cleanly at your maximum cost.

### Good to know

- Files are stored in the run's key-value store, which follows the platform's retention rules for run storage: download what you need, or move the files to storage of your own.
- AVIF gives the smallest files but is slower to encode. WebP is the best speed/size/compatibility trade-off.
- Only list images you have the right to process. Links to private/internal network addresses are refused.
- Memory: 1 GB handles 4 parallel images of up to ~24 megapixels (measured peak 509 MB). Raise the Actor memory and `concurrency` together for larger images.

### FAQ

**Is the download link public?** The output link is signed: anyone who has it can download the file, even though your storage stays private.

**Which input formats work?** JPEG, PNG, WebP, AVIF, GIF, TIFF and SVG. Anything else is reported as failed and is not charged.

**Can it handle very large photos?** Yes, but AVIF on very large images is slow and uses more memory; use a larger memory setting for batches of big files.

**Are failed images charged?** No.

### More Actors by clearcheck

- [Email Validator](https://apify.com/clearcheck/email-validator)
- [Domain Health Checker](https://apify.com/clearcheck/domain-health-checker)
- [Broken Link Checker and Sitemap SEO Auditor](https://apify.com/clearcheck/link-sitemap-audit)
- [PDF, DOCX and HTML to Markdown Converter](https://apify.com/clearcheck/document-to-markdown-converter)
- [Website Contact Finder](https://apify.com/clearcheck/website-contact-finder)
- [Bulk Phone Number Validator](https://apify.com/clearcheck/phone-validator)
- [OCR Text Extractor](https://apify.com/clearcheck/ocr-text-extractor)
- [Dataset Merger and Deduplicator](https://apify.com/clearcheck/dataset-merge-dedupe)
- [Excel and CSV to JSON Converter](https://apify.com/clearcheck/spreadsheet-to-json)

# Actor input Schema

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

Direct links to JPEG, PNG, WebP, AVIF, GIF, TIFF or SVG images (up to 2,000 per run, 30 MB and 100 megapixels each). Only use images you have the right to process. Duplicate URLs are ignored.

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

WebP is the best default (about 25-35% smaller than JPEG at equal quality, supported everywhere). AVIF is smaller still but slower. 'original' keeps each image in its own format.

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

Compression quality. 75-85 is visually lossless for most photos. For PNG, values below 100 enable palette quantisation (much smaller files).

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

Shrink images wider than this. 0 = no limit. Images are never enlarged.

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

Shrink images taller than this. 0 = no limit.

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

inside = keep aspect ratio and fit within the box (default). cover = fill the box exactly and crop. contain = fit and pad. fill = stretch.

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

Remove camera data, GPS position and other embedded metadata (recommended for privacy and smaller files). The image is still rotated correctly according to its orientation tag.

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

How many images are downloaded and processed at the same time. 4 is a good balance for 1 GB of memory; raise it together with the Actor memory.

## `timeoutSeconds` (type: `integer`):

Maximum wait for each image download.

## Actor input object example

```json
{
  "imageUrls": [
    "https://httpbin.org/image/jpeg",
    "https://httpbin.org/image/png"
  ],
  "format": "webp",
  "quality": 80,
  "maxWidth": 0,
  "maxHeight": 0,
  "fit": "inside",
  "stripMetadata": true,
  "concurrency": 4,
  "timeoutSeconds": 30
}
```

# Actor output Schema

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

Dataset with one item per image: download link, dimensions, bytes saved.

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

Key-value store holding the optimised images (keys img-0001-xxxx.webp...).

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

JSON with counts and total bytes saved.

# 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://httpbin.org/image/jpeg",
        "https://httpbin.org/image/png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("clearcheck/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://httpbin.org/image/jpeg",
        "https://httpbin.org/image/png",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("clearcheck/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://httpbin.org/image/jpeg",
    "https://httpbin.org/image/png"
  ]
}' |
apify call clearcheck/image-optimizer --silent --output-dataset

```

## MCP server setup

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