# WebP Converter – Compress Images in Bulk (`tidyrun/webp-converter`) Actor

Convert images to WebP in bulk and see exactly how many megabytes you saved: old size, new size and percent saved on every row. Quality or lossless, optional resize, one ZIP of the lot. $1 per 1,000 images; failed images are free.

- **URL**: https://apify.com/tidyrun/webp-converter.md
- **Developed by:** [Tidyrun](https://apify.com/tidyrun) (community)
- **Categories:** Developer tools, E-commerce, Automation
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 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.

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

## WebP Converter – Shrink Images in Bulk

Give it image URLs, get WebP files back — and a straight answer to "how much did I actually save?". Every row shows the old size, the new size and the percentage saved, so you can prove the win instead of guessing.

### Quick start

1. Paste your image links into **Image URLs** (or upload a text file with one URL per line).
2. Click **Start**.
3. The **Output** tab shows each WebP with its **Saved %**, and the run summary totals the megabytes.

Input example:

```json
{
  "imageUrls": [
    { "url": "https://example.com/photo.jpg" },
    { "url": "https://example.com/logo.png" }
  ],
  "quality": 80,
  "maxWidth": 1600,
  "zip": true
}
```

Output row (shortened):

```json
{
  "sourceUrl": "https://example.com/photo.jpg",
  "status": "converted",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/.../photo-3f1c2a9b7e.webp",
  "originalBytes": 546059,
  "webpBytes": 373905,
  "savedBytes": 172154,
  "savedPercent": 31.5,
  "width": 1280,
  "height": 853,
  "originalFormat": "jpeg",
  "chargedAsImages": 1
}
```

### Run it after a scraper

On your scraper or its task, open **Integrations**, search for this Actor and set its input:

```json
{
  "datasetId": "{{resource.defaultDatasetId}}",
  "urlField": "images.url"
}
```

Every time the scraper finishes, its images go through this Actor. Leave **URL field** empty and it finds the image links itself; use a dot path (`images.0.url`, `images.url` for a whole list) when you want one exact field. Each row keeps `recordIndexes`, the dataset rows the image came from.

### Settings worth knowing

| Setting | What it does |
| --- | --- |
| **Quality** | 80 by default: most photos look unchanged and lose about a third of their weight. Lower it for smaller files. |
| **Lossless** | Every pixel kept. Use it for logos, screenshots and line art. |
| **Max width / Max height** | Shrink anything bigger to fit. Aspect ratio is kept and small images are never enlarged. **Resizing saves far more than quality alone.** |
| **Put everything in one ZIP** | One file to download instead of clicking through a list. |
| **Max file size** | Skip source images bigger than this instead of spending the run on them. |

### Why this one

| Common problem | What happens here |
| --- | --- |
| "Did that actually help?" | Every row carries `originalBytes`, `webpBytes`, `savedBytes` and `savedPercent`, and the summary totals the megabytes saved. |
| Transparency turns black | Alpha is kept, so PNG logos stay transparent as WebP. |
| Animated GIFs lose their animation | Animated sources keep every frame. |
| Photos come out rotated | EXIF orientation is applied before encoding. |
| "Out of memory" on big batches | Images are encoded a few at a time within the run's memory, and an image too large to encode gets a clear error instead of crashing the run. |
| One site gets hammered and blocks you | At most 4 images at a time per site, with an automatic slow-down if a site rate-limits. |
| Paying for broken links | 404s, pages that are not images and oversized files are **never charged**. |
| Surprise bills on huge photos | Big images cost more to encode, so each row shows `chargedAsImages` before you scale up. |

Already-optimised images may shrink only a little, or not at all — the row still tells you exactly what happened.

### Pricing

Pay per converted image. Images that fail are never charged, and there is no fee just for starting a run.

An image up to **3 megapixels** (about 2048 × 1448, which covers ordinary web images) counts as one. Encoding cost follows pixels, so a much larger image counts as one more per 3 megapixels — a 24-megapixel photo counts as 8. Each row says what it was charged as in `chargedAsImages`, and **Max width** lowers both the file size and the count.

### Call it from your code

```bash
curl -X POST "https://api.apify.com/v2/acts/tidyrun~webp-converter/run-sync-get-dataset-items?token=YOUR_TOKEN" \
  -H 'Content-Type: application/json' \
  -d '{"imageUrls":[{"url":"https://example.com/photo.jpg"}],"quality":80}'
```

### Tips

- Shrinking for a website? Set **Max width** to the widest your layout ever shows (often 1600 px). That usually saves more than any quality setting.
- Logos and screenshots? Turn **Lossless** on; text edges stay crisp.
- Want the files saved as they are instead of converted? Use **Bulk Image Downloader** (`tidyrun/bulk-image-downloader`).

### Responsible use

Downloads the image URLs you provide, as an ordinary visitor. It does not log in, does not solve CAPTCHAs and does not collect personal data. Only convert images you have the right to use.

# Actor input Schema

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

Direct links to the images you want as WebP (JPEG, PNG, GIF, AVIF, TIFF, WebP). You can also upload a text file with one URL per line.

## `datasetId` (type: `string`):

Optional dataset, for example from a scraper run. Its image links are downloaded together with the URLs above, and each row keeps the dataset record index. When connected as an integration after a scraper, use {{resource.defaultDatasetId}}.

## `urlField` (type: `string`):

Field that holds the image link: a URL, a list of URLs, or objects with url/src. Dot paths work: images.0.url, or images.url for every image in a list. Leave empty to find image links automatically.

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

80 is the sweet spot: most photos look unchanged and lose half their weight. Lower it for smaller files, raise it for artwork with flat colour.

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

Keep every pixel exactly. Use it for logos, screenshots and line art. Files are bigger than lossless PNG only rarely.

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

Shrink anything wider to fit. Aspect ratio is kept and small images are never enlarged. Resizing saves far more than quality alone.

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

Shrink anything taller to fit. Works together with Max width.

## `zip` (type: `boolean`):

Also save all the WebP files as a single ZIP you can download in one click.

## `dedupe` (type: `boolean`):

Download each URL once, and save identical files (same SHA-256) once. Duplicate rows link to the first copy and are not charged.

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

Skip source images larger than this instead of spending the run on them.

## `timeoutSecs` (type: `integer`):

How long to wait for one image to download.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/1280px-Cat_November_2010-1a.jpg"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/The_Earth_seen_from_Apollo_17.jpg/1280px-The_Earth_seen_from_Apollo_17.jpg"
    }
  ],
  "quality": 80,
  "lossless": false,
  "zip": false,
  "dedupe": true,
  "maxFileSizeMb": 25,
  "timeoutSecs": 30
}
```

# Actor output Schema

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

One row per image: fileUrl, original and WebP size, bytes and percent saved, dimensions, and any error.

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

Images converted, megabytes before and after, total saved and the percentage.

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

Every WebP file saved by this run, plus the ZIP if you asked for one.

# 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": [
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/1280px-Cat_November_2010-1a.jpg"
        },
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/The_Earth_seen_from_Apollo_17.jpg/1280px-The_Earth_seen_from_Apollo_17.jpg"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("tidyrun/webp-converter").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": [
        { "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/1280px-Cat_November_2010-1a.jpg" },
        { "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/The_Earth_seen_from_Apollo_17.jpg/1280px-The_Earth_seen_from_Apollo_17.jpg" },
    ] }

# Run the Actor and wait for it to finish
run = client.actor("tidyrun/webp-converter").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": [
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Cat_November_2010-1a.jpg/1280px-Cat_November_2010-1a.jpg"
    },
    {
      "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/9/97/The_Earth_seen_from_Apollo_17.jpg/1280px-The_Earth_seen_from_Apollo_17.jpg"
    }
  ]
}' |
apify call tidyrun/webp-converter --silent --output-dataset

```

## MCP server setup

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

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/VRFJjpKBLlhtPdOAK/builds/cxyD7rVHJ4MJCcVtT/openapi.json
