# Image Converter & Resizer: WebP, AVIF, PNG, JPG (`klyve1/image-converter-resizer`) Actor

Convert and resize images in bulk from URLs: WebP, AVIF, PNG, JPEG, TIFF. Set width, height, fit, quality, strip metadata. Get download links and size savings for each image. Fast, powered by sharp.

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

## Pricing

from $2.00 / 1,000 image converteds

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 & Resizer: WebP, AVIF, PNG, JPG in bulk

Convert and resize hundreds of images from their URLs in one run. Pick the output format (WebP, AVIF, JPEG, PNG, TIFF, GIF), a width and/or height, a resize mode and a quality, and get a download link for every converted image together with its new size and how much space you saved.

Powered by [sharp](https://sharp.pixelplumbing.com/) (libvips), one of the fastest image processing libraries. Metadata such as EXIF and GPS location is removed by default.

### What people use it for

- **Faster websites and better Core Web Vitals**: turn heavy JPEG and PNG files into WebP or AVIF, often 30 to 80% smaller.
- **E-commerce catalogs**: resize product photos from a supplier feed to the exact size your shop needs.
- **Thumbnails**: create square thumbnails with Cover mode for galleries, marketplaces or apps.
- **Automation pipelines**: plug it after a scraper or in Make, Zapier or n8n to normalise every image you collect.
- **Privacy**: strip EXIF and GPS data from photos before publishing them.

### Example output

```json
{
  "sourceUrl": "https://www.gstatic.com/webp/gallery3/1.png",
  "outputUrl": "https://api.apify.com/v2/key-value-stores/<store-id>/records/1-5f710f.webp",
  "outputKey": "1-5f710f.webp",
  "sourceFormat": "png",
  "outputFormat": "webp",
  "sourceWidth": 400,
  "sourceHeight": 301,
  "width": 400,
  "height": 301,
  "sourceBytes": 113340,
  "outputBytes": 12606,
  "savedPercent": 88.9,
  "processingMs": 190
}
```

The converted files are stored in the run's key-value store. `outputUrl` is a direct download link. Images that cannot be downloaded or read get a row with an `error` field and are not charged.

### Input

| Field | What it does |
|---|---|
| Image URLs | Direct links to the images (JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG...). Max 50 MB each. |
| Output format | WebP, AVIF, JPEG, PNG, TIFF, GIF, or keep the original format. |
| Width / Height | Target size in pixels. Set one of them to keep the aspect ratio. |
| Resize mode | Inside (no crop), Cover (crop to fill), Contain (letterbox), Outside, Fill (stretch). |
| Quality | 1 to 100, default 80. |
| Allow upscaling | Off by default, so small images are never blurred. |
| Keep metadata | Off by default: EXIF, GPS and ICC data are removed. |
| Background color | Used for transparency when converting to JPEG and for Contain borders. |

### Pricing

Pay per result: **$0.002 per image converted** ($2 per 1,000 images). Failed downloads and unreadable files are free. Set a maximum charge per run to stay in control.

### Good to know

- Photos are automatically rotated according to their EXIF orientation before the metadata is removed.
- Animated GIF and WebP stay animated when the output is WebP or GIF.
- Files stay in the run's storage for the data retention period of your Apify plan: download them or copy them to your own storage if you need them longer.
- Only process images you have the right to use.

# Actor input Schema

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

Direct links to the images to convert (JPEG, PNG, WebP, AVIF, GIF, TIFF, SVG, HEIF with a supported codec). One per line. Max 50 MB per image.

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

Format of the converted images. WebP and AVIF give the smallest files for the web. "Keep original" only resizes and recompresses.

## `width` (type: `integer`):

Target width in pixels. Leave empty to keep the original width (or to compute it from the height).

## `height` (type: `integer`):

Target height in pixels. Leave empty to keep the aspect ratio from the width.

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

How to fit the image when both width and height are set. Inside keeps the whole image within the box, Cover fills the box and crops, Contain adds a background, Fill stretches.

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

Compression quality from 1 to 100. 75 to 85 is a good balance between size and quality.

## `allowEnlargement` (type: `boolean`):

Allow images smaller than the target size to be enlarged. Off by default to avoid blurry images.

## `keepMetadata` (type: `boolean`):

Keep the original metadata. Off by default: metadata is removed, which makes files smaller and removes GPS location for privacy.

## `background` (type: `string`):

Color used for transparent areas when converting to JPEG and for the borders in Contain mode, for example #ffffff.

## Actor input object example

```json
{
  "imageUrls": [
    "https://www.gstatic.com/webp/gallery/1.jpg",
    "https://www.gstatic.com/webp/gallery3/1.png"
  ],
  "format": "webp",
  "width": 800,
  "fit": "inside",
  "quality": 80,
  "allowEnlargement": false,
  "keepMetadata": false,
  "background": "#ffffff"
}
```

# Actor output Schema

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

All rows produced by the run.

# 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://www.gstatic.com/webp/gallery/1.jpg",
        "https://www.gstatic.com/webp/gallery3/1.png"
    ],
    "format": "webp",
    "width": 800
};

// Run the Actor and wait for it to finish
const run = await client.actor("klyve1/image-converter-resizer").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://www.gstatic.com/webp/gallery/1.jpg",
        "https://www.gstatic.com/webp/gallery3/1.png",
    ],
    "format": "webp",
    "width": 800,
}

# Run the Actor and wait for it to finish
run = client.actor("klyve1/image-converter-resizer").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://www.gstatic.com/webp/gallery/1.jpg",
    "https://www.gstatic.com/webp/gallery3/1.png"
  ],
  "format": "webp",
  "width": 800
}' |
apify call klyve1/image-converter-resizer --silent --output-dataset

```

## MCP server setup

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

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/sJNGxvM1k57BR2VYU/builds/KDsKMrbK5dolVtCfk/openapi.json
