# Image Converter — Convert, Resize to WebP, AVIF, PNG (`ponderable_hydrometer/image-converter`) Actor

Convert images by URL to WebP, AVIF, PNG or JPEG, with optional resizing and quality settings. Reports the size before and after. Each result links to the stored file.

- **URL**: https://apify.com/ponderable_hydrometer/image-converter.md
- **Developed by:** [Ponderable Hydrometer](https://apify.com/ponderable_hydrometer) (community)
- **Categories:** Automation, Developer tools, SEO tools
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $1.00 / 1,000 results

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

## Image Converter — Convert, Resize to WebP, AVIF, PNG

**Convert and shrink images in bulk.** Modern formats such as WebP and AVIF load faster and cost less to serve. Give it links, pick a format, and get stored files plus how many bytes you saved.

### What you get

One row per converted image: `imageUrl`, `fileUrl`, `format`, `width`, `height`, `originalBytes`, `bytes`, `savedPercent`, plus two flags: `lossless` (true when the file was written losslessly) and `largerThanOriginal` (true when the converted file is bigger than the source).

### Output sample

```json
{
  "imageUrl": "https://example.com/photo.png",
  "fileUrl": "https://api.apify.com/v2/key-value-stores/abc123/records/image-1.webp",
  "format": "webp",
  "width": 1200,
  "height": 800,
  "originalBytes": 912344,
  "bytes": 104211,
  "savedPercent": 89
}
```

### Input

| Field | Type | Default | Description |
|-------|------|---------|-------------|
| `imageUrls` | array | — | Direct links to images. |
| `format` | string | `"webp"` | webp, avif, png or jpeg. |
| `quality` | integer | `80` | From 1 to 100, for webp, avif and jpeg. |
| `maxWidth` | integer | `0` | Shrink wider images to this width. 0 keeps the size. |
| `maxHeight` | integer | `0` | Shrink taller images to this height. 0 keeps the size. |

### Good to know

- Images are never enlarged, and EXIF rotation is applied.
- WebP and AVIF: if the lossy file (at your `quality`) comes out as large as or larger than the source, the Actor also tries lossless encoding and keeps the smaller of the two (`lossless: true`). This is what turns small PNGs, line art and screenshots from bigger into smaller WebP files.
- The Actor always returns the format you asked for. If even the best encoding is larger than the source (for example a small PNG converted to JPEG, or an already optimised PNG), the row is still produced and billed as one result, but `savedPercent` is negative and `largerThanOriginal` is `true`, so you can filter those rows out or keep your original.
- A link that is not a readable image produces no row and no result fee.

### Pricing

Pay per result — **$1.00 per 1,000 results** (one converted image = one result), plus Apify's standard per-run start event ($0.00005 per GB of memory, so a fraction of a cent per run). No subscription.

# Actor input Schema

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

Direct links to images.

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

webp, avif, png or jpeg.

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

From 1 to 100, for webp, avif and jpeg.

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

Shrink wider images to this width. 0 keeps the size.

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

Shrink taller images to this height. 0 keeps the size.

## Actor input object example

```json
{
  "imageUrls": [
    "https://tesseract.projectnaptha.com/img/eng_bw.png",
    "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/testocr.png",
    "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/simple.png"
  ],
  "format": "webp",
  "quality": 80,
  "maxWidth": 0,
  "maxHeight": 0
}
```

# Actor output Schema

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

All rows produced by this run, as JSON.

# 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://tesseract.projectnaptha.com/img/eng_bw.png",
        "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/testocr.png",
        "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/simple.png"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("ponderable_hydrometer/image-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": [
        "https://tesseract.projectnaptha.com/img/eng_bw.png",
        "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/testocr.png",
        "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/simple.png",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("ponderable_hydrometer/image-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": [
    "https://tesseract.projectnaptha.com/img/eng_bw.png",
    "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/testocr.png",
    "https://raw.githubusercontent.com/naptha/tesseract.js/master/tests/assets/images/simple.png"
  ]
}' |
apify call ponderable_hydrometer/image-converter --silent --output-dataset

```

## MCP server setup

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