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

Convert public image URLs to WebP, AVIF, JPEG or PNG in bulk. Resize, strip metadata, and get file links with before/after sizes. API and MCP support.

- **URL**: https://apify.com/gunpark/image-converter-compressor.md
- **Developed by:** [Alejandro Rodriguez](https://apify.com/gunpark) (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 $1.60 / 1,000 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

## Bulk Image Converter & Compressor: WebP, AVIF, JPEG, PNG

Convert up to 100 public raster image URLs per run to WebP, AVIF, JPEG or PNG. Resize without enlargement, control lossy quality and strip metadata by default. Get one dataset row and a download link per successful image, with before/after byte sizes. Only the first animation frame is converted; output files can be larger than their inputs.

Use it for website assets, product-image preparation, content workflows, or AI agents that need smaller images. An MCP-enabled agent can supply URLs and read the resulting dataset/file links. No external conversion API or third-party API key is needed.

### Quick start

The default converts one small public PNG to WebP (verified on the Apify platform on 2026-11-20: completes in seconds, ~79% smaller).

```json
{
  "imageUrls": ["https://raw.githubusercontent.com/github/explore/main/topics/nodejs/nodejs.png"],
  "targetFormat": "webp",
  "quality": 80,
  "maxWidth": 1920,
  "maxHeight": 1920,
  "stripMetadata": true,
  "maxFileSizeMb": 50,
  "timeoutSeconds": 20
}
```

### For AI agents (MCP)

Actor ID: `gunpark/image-converter-compressor`. Minimal input: `{"imageUrls":["https://raw.githubusercontent.com/github/explore/main/topics/nodejs/nodejs.png"],"targetFormat":"webp"}`. Read `publicUrl`, `sizeBefore`, `sizeAfter`, `savingsPercent` and `warnings` from the dataset items. MCP server: `https://mcp.apify.com?tools=gunpark/image-converter-compressor` (running it requires an Apify account).

### Inputs

| Field | Default | Meaning |
| --- | --- | --- |
| `imageUrls` | One GitHub Explore PNG | 1–100 public HTTP(S) image URL strings, including public Apify file URLs. |
| `targetFormat` | `webp` | `webp`, `avif`, `jpeg` or `png`. |
| `quality` | `80` | 1–100 for WebP, AVIF and JPEG. PNG stays lossless and ignores this value. |
| `maxWidth` | `1920` | 1–8192 pixels. |
| `maxHeight` | `1920` | 1–8192 pixels. Image fits inside both bounds without enlargement. |
| `stripMetadata` | `true` | Strip input EXIF/XMP and other metadata. Set false to keep metadata supported by the encoder. |
| `maxFileSizeMb` | `50` | Download limit in MiB, from 1 to 50. |
| `timeoutSeconds` | `20` | 1–120 seconds for each download and separately each conversion. |

Input formats: PNG, JPEG, GIF, WebP and AVIF. Files must be publicly readable without authentication. Only public destinations on ports 80/443 are accepted, including redirect targets. SVG, HTML, PDF and TIFF are rejected. JPEG output flattens transparency onto white. EXIF orientation is applied before resizing. Only the first animation frame/page is converted, with a warning when the decoder reports multiple pages.

### Output

Illustrative item (sizes and IDs are examples):

```json
{
  "url": "https://example.org/photo.png",
  "key": "image-3cf98b6a-9a45-4a5d-90d2-6880d6f956b0.webp",
  "publicUrl": "https://api.apify.com/v2/key-value-stores/STORE_ID/records/image-3cf98b6a-9a45-4a5d-90d2-6880d6f956b0.webp",
  "targetFormat": "webp",
  "originalFormat": "png",
  "contentType": "image/webp",
  "width": 800,
  "height": 600,
  "sizeBefore": 100000,
  "sizeAfter": 25000,
  "savingsPercent": 75,
  "metadataStripped": true,
  "warnings": []
}
```

Sizes are bytes. Savings are `(1 - sizeAfter / sizeBefore) * 100`, rounded to two decimals. Negative savings mean the converted file is larger; compression is not guaranteed. `originalFormat` is the decoder's label (`heif` may identify AVIF). Width/height describe the converted image.

`publicUrl` uses the SDK's storage URL, including a signature when provided by the platform. Anyone with that link can access the file while it is retained. Local `apify run` produces a `file://` URL, which is local-only. Files are stored with matching MIME types and unique keys, not embedded in dataset rows.

`STATE` stores `convertedImages`, `failedImages` and `stoppedForChargeLimit`, plus `aborted: true` after cancellation. A failed image is skipped and counted; if every attempted image fails, the run is marked failed. Storage/upload errors fail the run rather than masquerading as a conversion success.

### Pricing

The custom pay-per-event unit is `image`, charged once per successfully stored image through `Actor.pushData(item, 'image')`. Failed conversions are not charged. The Actor checks the remaining image budget before the next file and stops when a charge reports `eventChargeLimitReached`.

One `image` event is charged per successfully converted image (see the pricing tab). Failed downloads/conversions are not charged an image event. Set "Max total charge" to cap any run.

### Limits

- At most 100 URLs per run, processed sequentially, 50 MiB per download/output, and 25 million decoded input pixels. Corrupt files and decoder warnings are rejected.
- The decoder/encoder runs locally with a timeout. Aborting cancels downloads and destroys the active conversion pipeline, saves counts and exits. Completed files remain available; aborting during storage may leave an unlisted file. Restarting does not resume work.
- Resizing and re-encoding can change colors and visual quality. Metadata removal is not redaction of text/faces visible in pixels. Keeping metadata may expose location or device information.
- No remote URL fetching occurs inside SVG/XML; those formats are rejected before native decoding. No animation preservation, custom ICC management, cropping or background selection.

### Legal and dependency licensing

Only process images you own or have permission to transform. Respect source terms, copyright and trademarks; a public URL does not grant reuse rights. Input URLs are saved in output rows. Avoid sensitive or token-bearing URLs and remember that output file links allow access to the image.

Direct runtime packages: `apify` (Apache-2.0), `sharp` (Apache-2.0) and `ipaddr.js` (MIT). **Licensing exception:** sharp depends on native libvips (LGPL-2.1-or-later), and prebuilt sharp-libvips distributions declare LGPL-3.0-or-later. Consequently, the requested sharp implementation cannot meet an all-permissive-transitive-dependencies requirement. See the [libvips repository](https://github.com/libvips/libvips) and [sharp-libvips licensing discussion](https://github.com/lovell/sharp-libvips/issues/270). sharp links libvips dynamically, consistent with the LGPL. No paid service is used.

### Local development

Built from `actors/template-cheerio`, using Node 24, ESM and Apify SDK 3.x:

```powershell
npm install --include=optional
npm test
../../tools/node_modules/.bin/apify.cmd validate-schema
New-Item -ItemType Directory -Force storage/key_value_stores/default
Copy-Item default-input.json storage/key_value_stores/default/INPUT.json
../../tools/node_modules/.bin/apify.cmd run
```

On Linux use `apify` instead of `apify.cmd`. Docker keeps optional dependencies because sharp's native Linux codecs require them. No deployment, login or account creation is performed here.

### More tools from the same author

- [PDF to Markdown & Text Extractor](https://apify.com/gunpark/pdf-to-markdown-extractor) – PDF URLs → Markdown/text/tables for RAG, flat $0.003 per PDF.
- [Bulk Image OCR](https://apify.com/gunpark/bulk-image-ocr) – image URLs → text (English & Spanish), $0.003 per image with text.
- [Bulk PageSpeed Insights & Core Web Vitals Audit](https://apify.com/gunpark/bulk-pagespeed-audit) – Lighthouse scores + real-user Core Web Vitals for many URLs or a sitemap.
- [Dataset Transformer](https://apify.com/gunpark/dataset-transformer) – filter, dedupe, sort any Apify dataset/JSON/CSV and export CSV/JSONL.

# Actor input Schema

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

1–100 public PNG, JPEG, WebP, AVIF or GIF URLs. Only the first animation frame is converted.

## `targetFormat` (type: `string`):

Output format. JPEG uses a white background for transparency.

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

Quality for WebP, AVIF and JPEG (1–100). PNG is lossless and ignores this value.

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

Fit inside these dimensions, preserving aspect ratio and never enlarging.

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

Fit inside these dimensions, preserving aspect ratio and never enlarging.

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

Remove EXIF, XMP and other input metadata. When false, keep metadata where supported.

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

Maximum downloaded bytes per file in MiB; streamed responses are also bounded.

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

Separate timeout for each download and each extraction/conversion.

## Actor input object example

```json
{
  "imageUrls": [
    "https://raw.githubusercontent.com/github/explore/main/topics/nodejs/nodejs.png"
  ],
  "targetFormat": "webp",
  "quality": 80,
  "maxWidth": 1920,
  "maxHeight": 1920,
  "stripMetadata": true,
  "maxFileSizeMb": 50,
  "timeoutSeconds": 20
}
```

# Actor output Schema

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

No description

## `state` (type: `string`):

No description

# 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 = {};

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

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

```

## MCP server setup

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