Image converter API: how to convert WEBP, PNG, JPG and GIF files (Python, cURL, no code)
Convert and resize images between PNG, JPEG, WEBP, GIF, BMP, TIFF and ICO, with quality, fit modes, transparency handling and optional metadata stripping. This guide shows the output fields, a working input, and
Python, JavaScript and cURL code for the Actor v0iddo/image-converter on Apify.
Open Image converter API on Apify
What data you get
One row per result. Every row can be downloaded as JSON, CSV, Excel or HTML, or read through the API.
| Field | Label | Type | Example |
|---|---|---|---|
index | # | number | 0 |
file_url | File | URL | https://api.apify.com/v2/key-value-stores/5kfOmYqKnt1Qb5KHM/records... |
filename | File name | text | converted.webp |
mime | Type | text | image/webp |
bytes | Bytes | number | 314 |
credits | Credits | number | 1 |
ms | Time (ms) | number | 62 |
file_key | text | result-001-converted.webp | |
from | text | png | |
to | text | webp | |
input_size | list | [24, 16] | |
output_size | list | [48, 32] | |
frames | number | 1 | |
metadata_stripped | true/false | true |
Input example
This is the input that is pre-filled on the Actor page. Change the values for your own run.
{
"file_base64": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAATUlEQVR42mOUX1z1n/UvEwOtMBMDjcHQt4AFl8TOpDSSDGqu2jTIfAADgTPm4U0lPbUhwzySBz4O1mckDVEfuM+bRVq5g8Oto6mIIAAA89w1GtnVjpwAAAAASUVORK5CYII=",
"to": "webp",
"width": 48,
"quality": 90
}
| Input field | Type | What it does |
|---|---|---|
file_url | string | Public http(s) URL of the file. |
file_urls | array | Many files in one run: one public http(s) URL per line, up to 1000. |
file_base64 | string | The file content as base64 (or a data: URI). |
to (required) | string | Target format |
width | integer | Target width in px |
height | integer | Target height in px |
fit | string | One of: inside, contain, cover, fill. |
quality | integer | jpeg / webp quality (webp 100 = lossless) |
strip_metadata | boolean | Drop EXIF / XMP / ICC (colours are converted to sRGB first) |
background | string | Colour for transparent areas when the target has no alpha, and for contain padding (default white / transparent) |
items | array | Optional. A list of input objects with the same fields as above; every object is processed in its own right and the top-level fields act as shared defaults. |
Output sample
Real rows from a run of the Actor. Fields that name people are left out of the sample.
[
{
"index": 0,
"file_url": "https://api.apify.com/v2/key-value-stores/5kfOmYqKnt1Qb5KHM/records/result-001-converted.webp?signature=1GJcHiq6LSLoT8O3nkDvo",
"file_key": "result-001-converted.webp",
"filename": "converted.webp",
"mime": "image/webp",
"bytes": 314,
"from": "png",
"to": "webp",
"input_size": [
24,
16
],
"output_size": [
48,
32
],
"frames": 1,
"metadata_stripped": true,
"credits": 1,
"ms": 62
}
]
Code: Python, JavaScript and cURL
Get your API token in Apify Console under Settings, then Integrations. The Actor id is v0iddo/image-converter.
Python (apify-client)
from apify_client import ApifyClient
client = ApifyClient("YOUR_APIFY_TOKEN")
run_input = {'file_base64': 'iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAATUlEQVR42mOUX1z1n/UvEwOtMBMDjcHQt4AFl8TOpDSSDGqu2jTIfAADgTPm4U0lPbUhwzySBz4O1mckDVEfuM+bRVq5g8Oto6mIIAAA89w1GtnVjpwAAAAASUVORK5CYII=',
'to': 'webp',
'width': 48,
'quality': 90}
run = client.actor("v0iddo/image-converter").call(run_input=run_input)
for item in client.dataset(run["defaultDatasetId"]).iterate_items():
print(item)
JavaScript (apify-client)
import { ApifyClient } from 'apify-client';
const client = new ApifyClient({ token: 'YOUR_APIFY_TOKEN' });
const input = {
"file_base64": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAATUlEQVR42mOUX1z1n/UvEwOtMBMDjcHQt4AFl8TOpDSSDGqu2jTIfAADgTPm4U0lPbUhwzySBz4O1mckDVEfuM+bRVq5g8Oto6mIIAAA89w1GtnVjpwAAAAASUVORK5CYII=",
"to": "webp",
"width": 48,
"quality": 90
};
const run = await client.actor('v0iddo/image-converter').call(input);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
console.log(items);
cURL
curl -X POST "https://api.apify.com/v2/acts/v0iddo~image-converter/run-sync-get-dataset-items" \
-H "Authorization: Bearer YOUR_APIFY_TOKEN" \
-H "Content-Type: application/json" \
-d '{"file_base64": "iVBORw0KGgoAAAANSUhEUgAAABgAAAAQCAYAAAAMJL+VAAAATUlEQVR42mOUX1z1n/UvEwOtMBMDjcHQt4AFl8TOpDSSDGqu2jTIfAADgTPm4U0lPbUhwzySBz4O1mckDVEfuM+bRVq5g8Oto6mIIAAA89w1GtnVjpwAAAAASUVORK5CYII=", "to": "webp", "width": 48, "quality": 90}'
Price
$1.00 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.70 per 1,000. See the pricing tab for your plan. A new Apify account gets $5 of platform credit every month.
FAQ
What data does the Image converter API return?
Each result is one row in an Apify dataset. Fields include index, file_url, filename, mime, bytes, credits, ms, file_key, and more. The table above shows every field with an example value.
How do I use the Image converter API from Python?
Install the apify-client package, create a client with your Apify API token, call the Actor v0iddo/image-converter with an input like the one above, and read the rows from the run's dataset. The Python snippet above does exactly that.
Can I use it without writing code?
Yes. Open the Actor page on Apify, fill in the input form (an example is already filled in), press Start, and download the results as JSON, CSV, Excel or HTML. You can also schedule runs there.
How much does it cost?
$1.00 per 1,000 results. You pay per result row. There is no separate charge per run. Higher Apify plans pay less per result, down to $0.70 per 1,000. A new Apify account gets $5 of platform credit every month.
How do I limit the number of results?
Set a maximum cost for a run in the run options on Apify, and the run stops when it is reached.
Can I send the results to Google Sheets, Make, Zapier or n8n?
Yes. Apify datasets connect to Google Sheets, Slack, Make, Zapier and n8n, and a webhook can call your own service when a run finishes. You can also export the dataset as JSON, CSV or Excel.
Open Image converter API on Apify
Related guides
- Google Maps Scraper: Scrape Google Maps business listings by search and place: name, category, address, coordinates, rating, rev...
- Bulk file and image downloader: Download files in bulk from direct links, or every image, video, audio file, PDF, document or archive on a...
- Video frame extractor: Extract still frames from video files as JPEG, PNG or WebP images with timecodes: one every N seconds, a nu...