# Image Convert API — AVIF, WebP, JPG & PNG (`epubpreflight/image-convert-api`) Actor

Convert, resize and optimize static AVIF, WebP, JPEG and PNG images in batches.

- **URL**: https://apify.com/epubpreflight/image-convert-api.md
- **Developed by:** [Ezra Evercreech](https://apify.com/epubpreflight) (community)
- **Categories:** Developer tools
- **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 standard 1units

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?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## Image Convert API

Convert static JPEG, PNG, WebP and AVIF images in batches. Resize without distortion or enlargement, apply EXIF orientation, and choose a background for transparent images converted to JPEG.

### Input

```json
{
  "urls": ["https://raw.githubusercontent.com/heavyrain39/webplified/main/banner.webp"],
  "options": { "format": "avif", "quality": 80, "width": 1280, "background": "#ffffff" }
}
```

| Option | Default | Supported values |
|---|---|---|
| format | webp | jpeg, png, webp, avif |
| quality | 80 | Integer 1–100; PNG ignores this option |
| width, height | Original size | Integer 1–8192; fit inside the bounding box, preserve ratio |
| background | #ffffff | #RRGGBB; used when removing transparency for JPEG |

Maximum 20 URLs per run, 20 MiB and 24 million pixels per input. Static 8-bit images only. Animated WebP/APNG, image sequences, HEIC, SVG, PDF and HDR workflows are unsupported. Output is converted to sRGB and metadata is stripped. Pixel dimensions determine processing cost even if the output is resized. Output cannot exceed 40 MiB. A conversion can increase file size; negative savings are reported honestly.

URL inputs must be publicly downloadable over HTTP(S), without cookies or authorization headers. Private/reserved IPs, nonstandard ports and unsafe redirects are rejected. Source URL parameters are not echoed into result rows. File processing is sequential, with a 30-second download deadline and 30-second image-processing timeout per file.

### Results

Each Dataset row contains `index`, `status`, input/output byte counts, dimensions, output format, `savings_percent`, `billable_units`, `billing_event`, and the result's `output_key`/`output_url`. Failed files produce an error row and no result event charge. `SUMMARY` records successful, failed, budget-skipped and recovered items plus SDK charge acknowledgements. If every file fails, the run fails too.

The result URL is a shareable URL to the run's Apify key-value store. Anyone holding it may be able to retrieve the file. Its lifetime follows the store's retention settings; this service does not provide permanent hosting or a guaranteed 24-hour expiry. Download results into your own storage. Raw downloaded inputs exist only in process memory. Apify retains the submitted input JSON and output records according to platform settings.

### Launch pricing (USD, platform usage included)

- JPEG/PNG/WebP: **$0.003 per image unit**.
- AVIF output: **$0.006 per image unit**.
- Each run: **$0.005**, including runs whose files fail.

An image up to 4 megapixels and up to 8 MiB combined input/output is one unit. Larger files use:

`units = max(1, ceil(input pixels / 4,000,000), ceil((input bytes + output bytes) / 8 MiB))`

Each successful file costs 1–8 units and generates **one** corresponding billing event. For example, 20 one-unit WebP outputs cost $0.065 total; AVIF costs $0.125. The run's spending limit is checked before downloads and again after the exact file charge is known. If the next file exceeds the budget, its output is not delivered or charged and the batch stops. A download/conversion may therefore occur before a larger file is found to exceed the remaining budget.

The fixed 2 GB run uses two automatic start events at $0.0025 each, totaling $0.005. There is no separate Dataset-row charge.

### Call from your application

Start an asynchronous run using your Apify token and an explicit spending limit:

```bash
curl -X POST "https://api.apify.com/v2/acts/epubpreflight~image-convert-api/runs?maxTotalChargeUsd=1" \
  -H "Authorization: Bearer $APIFY_TOKEN" \
  -H "Content-Type: application/json" \
  --data-binary @input.json
```

Save `data.id` from the response. Poll `GET /v2/actor-runs/{runId}` with the same authorization header until the run finishes. Read `GET /v2/datasets/{defaultDatasetId}/items` to obtain result rows and download each successful `output_url`.

Use only source files you have permission to process. For help, open an issue on this Actor and include the run ID, without posting confidential source URLs.

# Actor input Schema

## `urls` (type: `array`):

1–20 public image URLs; 20 MiB, 24 megapixels, static 8-bit images.

## `options` (type: `object`):

Output format, quality (ignored for PNG), maximum width/height, and JPEG background color. See README for billing units.

## Actor input object example

```json
{
  "urls": [
    "https://raw.githubusercontent.com/heavyrain39/webplified/main/banner.webp"
  ],
  "options": {
    "format": "avif",
    "width": 960,
    "quality": 60
  }
}
```

# Actor output Schema

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

No description

## `summary` (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 = {
    "urls": [
        "https://raw.githubusercontent.com/heavyrain39/webplified/main/banner.webp"
    ],
    "options": {
        "format": "avif",
        "width": 960,
        "quality": 60
    }
};

// Run the Actor and wait for it to finish
const run = await client.actor("epubpreflight/image-convert-api").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 = {
    "urls": ["https://raw.githubusercontent.com/heavyrain39/webplified/main/banner.webp"],
    "options": {
        "format": "avif",
        "width": 960,
        "quality": 60,
    },
}

# Run the Actor and wait for it to finish
run = client.actor("epubpreflight/image-convert-api").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 '{
  "urls": [
    "https://raw.githubusercontent.com/heavyrain39/webplified/main/banner.webp"
  ],
  "options": {
    "format": "avif",
    "width": 960,
    "quality": 60
  }
}' |
apify call epubpreflight/image-convert-api --silent --output-dataset

```

## MCP server setup

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

```

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/oMswp25UxTHEq6OhV/builds/beWinehorFvUFt4FB/openapi.json
