# Image Converter: JPEG, PNG, WebP and AVIF, resize and compress (`examsens.ai/image-converter`) Actor

Converts every image URL you list to JPEG, PNG, WebP or AVIF, resizes by width, height or fit, compresses to the quality you set, and strips metadata. Returns a download link for each file.

- **URL**: https://apify.com/examsens.ai/image-converter.md
- **Developed by:** [Ed Rayyis](https://apify.com/examsens.ai) (community)
- **Categories:** For creators, Developer tools
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

from $9.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: JPEG, PNG, WebP and AVIF, resize and compress

Give it a list of image URLs and it converts each one to WebP, AVIF, JPEG or PNG, resizes it, compresses it to the quality you set, and strips the metadata. Every new file goes into the run's key value store, and the dataset gives you a direct download link with the size before and after.

### What it does

- Converts to WebP, AVIF, JPEG or PNG, or keeps each image in its own format
- Resizes by width, height or both, with four fits:
  - Inside: keeps the aspect ratio and fits within the box
  - Cover: fills the box and crops the overflow from the center
  - Contain: fits inside the box and pads to the exact size with your background color
  - Fill: stretches to the exact size
- Never enlarges by default: an image smaller than the target keeps its own size. Turn this off to scale small images up.
- Compresses JPEG, WebP and AVIF to a quality from 1 to 100. WebP also has a lossless mode, for logos, screenshots and line art.
- Strips metadata by default: EXIF (including GPS coordinates), XMP and the color profile are removed. An image with a color profile other than sRGB, such as Display P3, is converted to sRGB first so its colors stay right.
- Turns photos upright from their EXIF orientation before resizing, so portrait photos stay portrait.
- Keeps transparency in PNG, WebP and AVIF. For JPEG, transparent areas are filled with the background color.

Reads JPEG, PNG, WebP, AVIF, TIFF and GIF. An animated GIF is converted from its first frame, and the item says so in `note`.

### Example

A 550 by 368 JPEG of 44,891 bytes, converted to WebP at 400 pixels wide and quality 80, came out at 400 by 268 and 19,328 bytes: 56.9% smaller. A PNG of 224,566 bytes with transparency came out as a 152,822 byte lossless WebP with every pixel identical.

### Input

- Image URLs (required)
- Output format: WebP (default), AVIF, JPEG, PNG, or same as the original (JPEG, PNG, WebP and AVIF stay as they are; any other format becomes PNG)
- Width and height in pixels (optional; leave both empty to keep the size)
- Fit: inside (default), cover, contain or fill. Cover, contain and fill need both width and height.
- Never enlarge (default on)
- Quality (default 80)
- Lossless WebP (default off)
- Strip metadata (default on). When off, EXIF (GPS included), XMP and the color profile are copied to the new file. IPTC blocks are not copied.
- Background color (default white), a CSS color such as `#ffffff` or `white`
- Maximum file size in MB (default 50): larger source files get an error item
- Parallel images (default 4)

### Output

Dataset: one item per URL with `outputUrl` (download link), `outputKey` (the file name in the key value store), `inputFormat`, `outputFormat`, `inputWidth`, `inputHeight`, `outputWidth`, `outputHeight`, `inputBytes`, `outputBytes`, `savedPercent`, `metadataStripped`, and `convertedToSrgb` when the image had a color profile. Files are named by their position in your list and the source file name, such as `0001-photo.webp`.

A URL that cannot be converted gets `ok: false` and an `error`, such as `HTTP 404`, an unknown host, a file over the size limit, or "the file is not an image format this actor can read" for a web page. One bad URL never stops the run.

### Pricing

Pay per event: one event per image converted. URLs that fail are not charged. The run stops when it reaches the maximum charge you set.

### Scope and conduct

Only the URLs you supply are downloaded. The actor does not log in anywhere and uses no proxies. Convert images you have the right to use.

### Support

Questions and problems: the Issues tab on this page. Replies are written by an AI assistant on behalf of the developer and reviewed by the developer.

# Actor input Schema

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

Direct links to image files (JPEG, PNG, WebP, AVIF, GIF, TIFF and other formats Pillow reads).

## `outputFormat` (type: `string`):

WebP and AVIF give the smallest files. JPEG opens everywhere. PNG is lossless and keeps transparency. Same as the original keeps each image's own format (JPEG, PNG, WebP or AVIF; any other format becomes PNG).

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

Target width in pixels. 0 or empty means no width limit.

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

Target height in pixels. 0 or empty means no height limit.

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

Inside: keep the aspect ratio and fit within the width and height. Cover: fill the width and height and crop the overflow from the center. Contain: fit inside and pad to the exact width and height with the background color. Fill: stretch to the exact width and height. Cover, Contain and Fill need both width and height.

## `withoutEnlargement` (type: `boolean`):

Leave images that are already smaller than the target at their own size.

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

1 to 100 for JPEG, WebP and AVIF. Lower gives smaller files. PNG is always lossless and ignores this.

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

Encode WebP without loss. Good for logos, screenshots and line art.

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

Remove EXIF (including GPS), XMP and the color profile. An image with a color profile other than sRGB is converted to sRGB first so its colors stay right. When off, EXIF, XMP and the color profile are copied to the new file.

## `backgroundColor` (type: `string`):

Fills transparent areas when saving as JPEG, and the padding for the Contain fit. A CSS color such as #ffffff or white.

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

Skip source images larger than this, with an error item.

## `maxConcurrency` (type: `integer`):

How many images to download and convert at the same time.

## Actor input object example

```json
{
  "imageUrls": [
    {
      "url": "https://www.gstatic.com/webp/gallery/1.jpg"
    }
  ],
  "outputFormat": "webp",
  "fit": "inside",
  "withoutEnlargement": true,
  "quality": 80,
  "lossless": false,
  "stripMetadata": true,
  "backgroundColor": "#ffffff",
  "maxFileSizeMb": 50,
  "maxConcurrency": 4
}
```

# Actor output Schema

## `results` (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 = {
    "imageUrls": [
        {
            "url": "https://www.gstatic.com/webp/gallery/1.jpg"
        }
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("examsens.ai/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": [{ "url": "https://www.gstatic.com/webp/gallery/1.jpg" }] }

# Run the Actor and wait for it to finish
run = client.actor("examsens.ai/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": [
    {
      "url": "https://www.gstatic.com/webp/gallery/1.jpg"
    }
  ]
}' |
apify call examsens.ai/image-converter --silent --output-dataset

```

## MCP server setup

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