# PNG to JPG Converter - WebP, AVIF and More (`marcel-rbro/png-to-jpg`) Actor

Convert PNG to JPG online in seconds. Also converts WebP, AVIF, JFIF, BMP, TIFF and GIF in any direction. Transparency is flattened onto a background colour you choose rather than silently onto black. Up to 100 images per run, with resize and quality.

- **URL**: https://apify.com/marcel-rbro/png-to-jpg.md
- **Developed by:** [Marcel Rebro](https://apify.com/marcel-rbro) (community)
- **Categories:** Developer tools, Automation
- **Stats:** 2 total users, 1 monthly users, 0.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
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.
Actors are written with capital "A".

## 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.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

Convert **PNG to JPG** online, plus WebP, AVIF, JFIF, BMP, TIFF and GIF, in any direction. Convert one image or a whole folder of up to 100 in a single run, and get a ZIP back. Transparent backgrounds are flattened onto a colour you choose rather than the black most converters leave you with.

Every one of these formats exists because it is better than the others at something, which is why none of them won and why you keep having to convert between them. PNG carries transparency and no compression artefacts. JPG opens in absolutely everything. WebP and AVIF are a third the size but only if whatever is receiving them understands them. This converter is the boring step in between.

- 🖼️ **Eight formats in, six out** - PNG, JPG, JFIF, WebP, AVIF, BMP, TIFF and GIF in; JPEG, PNG, WebP, AVIF, TIFF and BMP out
- 📁 **Converts a whole folder in one run** - up to 100 images, returned as a single ZIP, for roughly what one image costs
- 🩶 **Transparency handled properly** - JPG cannot store a transparent background, so choose the colour it becomes instead of discovering it went black
- 🎨 **Fixes oversaturated wide-gamut images** - a real sRGB conversion, not a relabelling
- 📍 **Strips GPS and EXIF on request** - one switch before you share a photo publicly
- 📐 **Resizes while it converts** - cap the long edge without a second tool
- 💸 **Costs a fraction of a cent per image**
- 🔌 **Runs from the API, a schedule or an integration** - it is an Apify Actor, so Zapier, Make, n8n and MCP clients can call it

Converting photos off an iPhone? Those are HEIC files, and the
[HEIC to JPG converter](https://apify.com/marcel-rbro/heic-to-jpg) is the Actor built for them - it
handles bursts and Live Photo stills, which this one does not. This Actor is the web-formats one.

### How to convert PNG to JPG

1. Click **Try for free** and sign in to Apify.
2. Upload your `.png` file in the **Images** field, or paste a direct URL to it. You can add up to 100 files here.
3. Leave **Convert to** on `jpeg`, or pick another format.
4. If your PNG has a transparent background, set **Background colour** to whatever it should become. The default is white.
5. Click **Start**, then download the JPG from the **Storage** tab or from the download URL in the run's dataset record.

#### How to batch convert a folder of images

Add every file to the **Images** field - up to 100 per run - and start the run. Each image is converted
separately with the same settings, and:

- Every converted image lands in the run's storage under its own filename.
- They are also packed into one `images.zip`, which is what the **Output** tab and the API hand back,
  so you download once rather than a hundred times.
- The run's dataset gets **one record per input file**, with an `ok` flag, so you can see at a glance
  what converted and what did not.

**One bad file does not spoil the batch.** A PDF that slipped into the folder, a URL that 404s or a
truncated download is recorded against that file with the reason and the run carries on. The run only
fails if nothing at all converted. Two files called `IMG_0001.png` from two different folders both
come out, as `IMG_0001.jpg` and `IMG_0001-2.jpg`, rather than one silently replacing the other.

This is also much cheaper than running the Actor once per file - see
[the cost section](#how-much-does-it-cost-to-convert-png-to-jpg).

#### How to convert WebP to JPG

Upload a `.webp` file and leave **Convert to** on `jpeg`. WebP is what image CDNs and modern sites
serve, so it is what you get when you save a picture from a web page - and then Word, older Photoshop
and half the upload forms on the internet refuse it. A WebP can be transparent, so set the background
colour if it is.

#### How to convert WebP to PNG

Same file, set **Convert to** to `png`. This is the conversion to choose when the WebP has a
transparent background you need to keep: PNG stores transparency and JPG does not. It is also
lossless, so nothing is re-compressed on the way through - the file will be considerably larger.

#### How to convert AVIF to JPG

Upload an `.avif` file and leave **Convert to** on `jpeg`. AVIF is the newest of these formats and
the smallest at a given quality, which is exactly why software that is more than a couple of years
old cannot open it. AVIF supports transparency, so the background colour applies here too.

#### How to convert PNG to WebP

Set **Convert to** to `webp`. This is the conversion for making a page faster: WebP is meaningfully
smaller than PNG at the same visible quality and every current browser reads it. Transparency
survives, so a logo stays a logo. Drop **Quality** to around 80 if size matters more than the last
sliver of detail.

#### How to convert JFIF to JPG

Upload the `.jfif` file and leave **Convert to** on `jpeg`. Worth knowing what you are actually
converting: **a `.jfif` file is already a JPEG**. JFIF is the interchange format JPEG has been
wrapped in since 1992, and some versions of Windows and some email clients simply save it under that
extension instead of `.jpg`. Nothing about the image changes - this conversion re-writes the file
with the extension everything else expects. The Actor reads the header rather than the filename, so
it reports what the file genuinely is in the run's dataset record.

#### How to convert JPG to PNG

Set **Convert to** to `png`. Useful when something downstream insists on PNG, or when you want a
lossless copy to edit without accumulating JPEG artefacts every time you save. It cannot undo
compression that has already happened: a PNG made from a JPG is a perfect copy of an imperfect
image, and it will be several times larger.

#### Converting BMP, TIFF and GIF

All three go through the same path. BMP and TIFF are the formats that turn up from scanners, medical
software and anything descended from Windows 95; GIF is a picture with at most 256 colours. Any of
them convert to any of the six output formats.

### What happens to transparency when you convert PNG to JPG?

This is the thing most converters get wrong, so it is worth being explicit.

PNG, WebP, AVIF, TIFF and GIF can all store a transparent background. **JPEG cannot** - the format
has no alpha channel and never has. So converting a transparent image to JPG is not a conversion,
it is a decision: something has to go behind the picture.

Most tools make that decision by accident. The transparent pixels are usually stored as black with an
alpha value of zero, so dropping the alpha channel reveals black, and the logo you converted comes
back on a black rectangle. **This Actor flattens onto white by default and lets you pick any other
colour** with the `backgroundColor` input. A colour name, `#ffffff`, or `rgb(255,255,255)` all work,
and a colour ImageMagick does not recognise stops the run with an explanation instead of quietly
falling back to black.

Three consequences worth knowing:

- **BMP output is flattened too.** 32-bit BMP can technically carry transparency, but a great many of
  the old Windows applications people choose BMP for render it as a black rectangle. Anyone picking
  BMP is picking it for compatibility, so this Actor gives them the compatible thing.
- **PNG, WebP, AVIF and TIFF output keep transparency exactly as it was**, and `backgroundColor` is
  ignored. The run log says so when you set it anyway.
- **`transparent` is not a valid background colour for JPG output.** It is accepted by ImageMagick and
  produces black, so the Actor refuses it and tells you to choose PNG or WebP instead.

The run's dataset record reports `sourceHasAlpha`, `alphaFlattened` and the `backgroundColor` used,
so you can tell after the fact whether a conversion made that decision for you.

### Input

Upload the files in the **Images** field, or pass direct URLs to them.

| Field | Description |
|---|---|
| `files` | The images to convert, up to 100. File uploads or URLs. |
| `file` | One image, as a URL. A hidden alias kept so existing API callers keep working; ignored when `files` is set. |
| `outputFormat` | `jpeg` (default), `png`, `webp`, `avif`, `tiff` or `bmp`. |
| `quality` | 1 to 100, default 90. Used by JPEG, WebP and AVIF; ignored by the lossless formats. |
| `backgroundColor` | What transparent areas become when the output cannot store them. `white` by default. |
| `maxDimension` | Shrink so neither side exceeds this many pixels. Never enlarges. |
| `keepMetadata` | `true` by default. Set to `false` to strip EXIF, XMP and IPTC. |
| `stripToSRGB` | Convert into sRGB and drop the embedded colour profile. `false` by default. |
| `outputFilename` | Defaults to the input filename. Single-image only; ignored for a batch. |
| `fileBase64`, `filename` | The file as base64, for API callers who prefer JSON to a URL. |
| `verboseLog` | Include the full ImageMagick output in the Actor log. |

#### Does the converted image keep EXIF, GPS and camera data?

`keepMetadata` is on by default, because silently discarding the date a photo was taken is the more
surprising behaviour. Note what that means for phone photos: the EXIF block carries the camera model,
the timestamp and, if location services were on, **the GPS coordinates where the photo was taken**.
Turn `keepMetadata` off before sharing images publicly.

Stripping metadata deliberately keeps the ICC colour profile. Removing that too would visibly shift
the colours of wide-gamut images, which is not what anyone means by "strip the metadata". It also
removes the timestamps ImageMagick writes into PNG files of its own accord, which a naive strip
leaves behind.

#### My PNG looks washed out or oversaturated after converting

Turn on `stripToSRGB`. Images from an iPhone, a modern camera or Photoshop are frequently in a
wide-gamut colour space - Display P3 or Adobe RGB - and carry a profile telling viewers how to
interpret them. Software that ignores that profile shows the numbers as though they were sRGB, and
the result is either garish or flat depending on which way the mismatch runs.

`stripToSRGB` performs a real colour-managed conversion into sRGB and then removes the profile, so
the pixels themselves are correct and nothing downstream has to interpret anything. It is off by
default because it is a lossy narrowing of the colour range, and an image already in sRGB gains
nothing from it.

### Output

Every converted image is written to the run's key-value store under its own filename, so it is
downloadable from the **Storage** tab. What lands under `OUTPUT` - which is what the **Output** tab
shows and what `run-sync` returns in its HTTP response body - depends on how many files went in:

| Input | `OUTPUT` holds |
|---|---|
| One image | the converted image itself |
| Several images | `images.zip`, containing every converted image |
| Several images totalling over 192 MB | `MANIFEST.json`, listing every image with its key, size and URL |

That last row exists because the ZIP is assembled in memory before it is uploaded. Past a couple of
hundred megabytes of output, building it would cost more memory than the conversion did, so the run
lists the results instead. Every image is still in storage under its own name either way.

**The dataset gets one record per input file**, each with an `ok` flag, the detected source format,
dimensions, file sizes, how transparency was handled and the download URL. A file that failed gets a
record too, with `ok: false` and the reason in `error`. Records are written as each file finishes, so
a run that dies at file 80 still has the first 79 results.

Note that the source format in that record comes from reading the file's header, not its extension.
A `.jfif` is reported as JPEG, and a `.png` that is secretly a JPEG is reported as what it is, with a
warning in the log.

### How much does it cost to convert PNG to JPG?

| Job | Run time | Cost |
|---|---|---|
| One 2 MP PNG | 6.8 s | **$0.0006** |
| 50 PNGs in one run | 120 s | **$0.011**, or $0.0002 each |

Measured 2026-08-26 on the Free plan at the default 1024 MB, read back from the run API.

**An image costs a fraction of a cent**, and Apify's [free plan](https://apify.com/pricing) includes
$5 of usage a month - tens of thousands of images.

**Batch, but for the right reason.** A run spends about four seconds starting the container before it
converts anything, and that is paid once per run however many files it handles. Fifty images as fifty
separate runs costs around $0.030; the same fifty in one run costs $0.011. So batching is roughly
three times cheaper - a real saving, but not the hundred-fold one you might expect, because past the
startup each image still costs its own couple of seconds of conversion.

Compute is a little over half the bill. The rest is key-value store writes and data transfer, which
scale with the number of output files rather than with run time.

Leave the memory at the default 1024 MB. Apify allocates one CPU core per 4096 MB, and a conversion
this short is not CPU-bound long enough for extra cores to pay for themselves. Raise it only for very
large images converted to PNG or TIFF, where the uncompressed pixel buffer is the constraint.

### How to convert PNG to JPG with the API

`run-sync` returns the image in the response body:

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/marcel-rbro~png-to-jpg/run-sync?token=<TOKEN>" \
  -H 'Content-Type: application/json' \
  -d '{"file": "https://example.com/logo.png", "outputFormat": "jpeg", "quality": 90, "backgroundColor": "white"}' \
  --output logo.jpg
```

A whole folder in one run, which returns the ZIP:

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/marcel-rbro~png-to-jpg/run-sync?token=<TOKEN>" \
  -H 'Content-Type: application/json' \
  -d '{"files": ["https://example.com/a.png", "https://example.com/b.webp"], "outputFormat": "jpeg"}' \
  --output images.zip
```

WebP to PNG, keeping the transparency:

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/marcel-rbro~png-to-jpg/run-sync?token=<TOKEN>" \
  -H 'Content-Type: application/json' \
  -d '{"file": "https://example.com/icon.webp", "outputFormat": "png"}' \
  --output icon.png
```

If you hold the bytes rather than a URL, pass them as base64 in `fileBase64`. The Apify API requires
Actor input to be `application/json`, so posting the image as a raw request body is rejected with
HTTP 400 before the run starts - a URL or base64 are the two ways in:

```bash
curl -X POST \
  "https://api.apify.com/v2/acts/marcel-rbro~png-to-jpg/run-sync?token=<TOKEN>" \
  -H 'Content-Type: application/json' \
  -d "{\"fileBase64\": \"$(base64 < logo.png)\", \"filename\": \"logo.png\"}" \
  --output logo.jpg
```

Base64 adds about a third to the payload, so prefer a URL for large files.

`run-sync` waits up to 300 seconds, which no ordinary image will come close to using. There are
[client libraries for JavaScript and Python](https://docs.apify.com/api/client), and the same run can
be triggered on a schedule or from Zapier, Make, n8n, Slack or an MCP client.

### Limitations

- **100 images per run**, and the run is capped at 512 MB of input in total, 100 MB for any one file,
  100 MP for any one image and 2 GP across the whole run. Anything larger is refused with a message
  naming the limit rather than timing out halfway through. Split the batch and run it again for the rest.
- **Every image in a run gets the same settings.** One output format, one quality, one background
  colour. Converting some files to PNG and others to JPG means two runs.
- **Over 192 MB of output comes back as a manifest rather than a ZIP.** The archive is built in
  memory, so past that point the run lists the results instead of packing them. The images themselves
  are in storage either way.
- **Downloads are given 120 seconds each.** A URL that hangs is recorded as a failure for that file
  rather than stalling everything queued behind it.
- **Animated images convert their first frame only.** An animated GIF, an animated WebP or an APNG
  becomes a single still image, and the run log says so. None of the output formats here store
  animation.
- **No vector input.** SVG is a drawing rather than a grid of pixels, and rasterising one needs a
  renderer this Actor does not carry. Uploading one fails with an explanation rather than a delegate
  error.
- **No PDF, in or out.** Use [PDF to JPG](https://apify.com/marcel-rbro/pdf-to-jpg) and
  [JPG to PDF](https://apify.com/marcel-rbro/jpg-to-pdf) for those directions.
- **HEIC works, but is not what this Actor is for.** A `.heic` file uploaded here converts, with a
  note in the log pointing at the [HEIC to JPG converter](https://apify.com/marcel-rbro/heic-to-jpg),
  which handles bursts, Live Photo stills and multi-image containers that this one does not.
- **Format availability is asserted at build time.** Reading and writing all seven formats is checked
  when the image is built, along with a round trip proving the alpha channel survives every format
  that claims to store one. A delegate library that quietly loses a codec fails the build rather than
  every run.

### Other file converters

| Actor | Converts | Use it for |
|---|---|---|
| **PNG to JPG converter** (this one) | PNG, JPG, JFIF, WebP, AVIF, BMP, TIFF, GIF → JPEG, PNG, WebP, AVIF, TIFF, BMP | Web and desktop image formats |
| [HEIC to JPG converter](https://apify.com/marcel-rbro/heic-to-jpg) | HEIC, HEIF, AVIF → JPEG, PNG, WebP, AVIF, TIFF | **iPhone photos**, bursts and Live Photo stills |
| [PDF to JPG converter](https://apify.com/marcel-rbro/pdf-to-jpg) | PDF → JPEG, PNG | Turning pages into images |
| [JPG to PDF converter](https://apify.com/marcel-rbro/jpg-to-pdf) | JPEG, PNG → PDF | Turning images into a document |
| [Word to PDF converter](https://apify.com/marcel-rbro/word-to-pdf) | DOC, DOCX → PDF | Office documents |
| [MOBI to EPUB converter](https://apify.com/marcel-rbro/mobi-to-epub) | MOBI, PRC, AZW, AZW3 → EPUB | Kindle ebooks |
| [EPUB to PDF converter](https://apify.com/marcel-rbro/epub-to-pdf) | EPUB → PDF | Ebooks for printing |

The overlap with the HEIC Actor is only AVIF, and it is deliberate - both read it. Everything else is
a clean split: **that one is for the HEIF family your phone produces, this one is for the formats the
web runs on.**

### FAQ

#### Is this PNG to JPG converter free?

Apify's free plan includes $5 of platform usage per month and needs no card. At a fraction of a cent
per image, that covers a great many conversions before you pay anything.

#### What happens to a transparent background?

It becomes the colour you set in `backgroundColor`, which defaults to white, whenever the output
format cannot store transparency - that means JPG and BMP. PNG, WebP, AVIF and TIFF output keep it
untouched. The full explanation is in
[the transparency section above](#what-happens-to-transparency-when-you-convert-png-to-jpg).

#### Does converting PNG to JPG lose quality?

Yes, in two ways. JPEG is lossy, so the encode discards detail - at the default quality of 90 that is
invisible at normal viewing sizes. And it drops the alpha channel, which is not recoverable at all:
once a transparent background has been flattened onto white, converting back to PNG gives you a white
background, not a transparent one. Keep the original if you might need it.

Going the other way, JPG to PNG, loses nothing on the conversion itself, but it cannot repair
compression the JPEG already applied.

#### WebP, AVIF or JPG - which should I use?

Roughly, in order of age:

- **JPG** is thirty years old, has no transparency, and opens in literally everything. Choose it when
  you do not control what will open the file.
- **WebP** is meaningfully smaller than JPG at the same visible quality, supports transparency, and is
  read by every current browser and most current software. Choose it for the web.
- **AVIF** is smaller again, supports transparency, and is the one most likely to be refused by
  whatever you hand it to. Choose it when you know the receiving end is modern.

PNG is not really in that comparison: it is lossless, so it is the right answer for logos, screenshots
and diagrams, and the wrong answer for photographs, where it produces enormous files.

#### Is JFIF the same as JPG?

Yes. JFIF is the container JPEG data has been stored in since 1992, and `.jfif` is simply a different
extension for the same file - some Windows versions and email clients save it that way. Renaming it to
`.jpg` usually works. Converting it here re-writes the file properly and tells you what the header
actually says, which is useful when the file turns out not to be a JPEG at all.

#### Why is my JPG larger than the PNG it came from?

Because PNG compresses flat colour extremely well. A logo, a screenshot or a diagram is mostly large
areas of identical pixels, which is the case PNG was designed for and the case JPEG is worst at - JPEG
also has to spend bits inventing texture where the image had none. For that kind of image, PNG or WebP
is the smaller and better-looking choice, and converting to JPG is only worth it when something
downstream demands JPG.

For photographs the relationship reverses, and JPG is dramatically smaller.

#### Can I convert a batch of images?

Yes, and it is the cheapest way to use this Actor. Put up to 100 files in the **Images** field and
they are all converted in one run, coming back as a single `images.zip`. Because container startup is
most of what a run costs, a batch of 100 costs roughly what one image does - converting a folder as
100 separate runs pays that startup 100 times for no reason.

One bad file does not spoil the batch: it is recorded against its own dataset record with the reason
and the run carries on. The run only fails if nothing converted at all.

#### Can an AI agent call this converter?

Yes. Every Apify Actor is exposed through the
[Apify MCP server](https://docs.apify.com/platform/integrations/mcp), so Claude, Cursor and other MCP
clients can run this conversion as a tool. The Actor's input schema is what the agent sees, so
`files`, `outputFormat` and `backgroundColor` are available to it without any extra wiring - an agent
can hand it a list of URLs and get one archive back.

#### Should I use this or the HEIC to JPG converter?

If the file came off an iPhone, or has a `.heic`, `.heif` or `.hif` extension, use the
[HEIC to JPG converter](https://apify.com/marcel-rbro/heic-to-jpg). It is built for that family and
handles bursts and multi-image containers. For anything that came off the web or out of an image
editor - PNG, JPG, WebP, AVIF, JFIF, BMP, TIFF, GIF - use this one. AVIF works in both.

#### The conversion failed. What now?

Turn on `verboseLog` and re-run: the Actor log will carry ImageMagick's own error. The Actor reads the
file header before converting, so most bad inputs are named rather than guessed at - a PDF, an SVG, an
HTML error page returned by a URL, or a video file are all reported as what they are. The remaining
common causes are a truncated upload and a `backgroundColor` that is not a colour.

### Development

```bash
npm install
npm test      # tests the header inspector, the batch budgets and the ZIP writer; no ImageMagick needed
apify run     # needs ImageMagick on your PATH
```

Conversion runs ImageMagick in a Debian container. The image is built on Debian trixie rather than
bookworm on purpose: bookworm's ImageMagick 6 is built against libheif 1.15.1, which cannot carry an
alpha channel through AVIF in either direction, so a transparent AVIF converted to JPG came out black.
Trixie's ImageMagick 7 against libheif 1.19.8 handles it, and matches the version most people have
locally, so `apify run` behaves the same as the deployed image. The Actor detects `magick` or
`convert` at startup, so either version works.

This Actor's code is MIT licensed. ImageMagick and its delegate libraries run as separate processes
under their own licences - see [THIRD\_PARTY\_NOTICES.md](THIRD_PARTY_NOTICES.md).

# Actor input Schema

## `files` (type: `array`):

The images to convert. Upload files or paste direct URLs - up to 100 per run. Each one is converted separately and the results come back as a single ZIP. Accepts .png, .jpg, .jpeg, .jfif, .webp, .avif, .bmp, .tiff and .gif.

## `file` (type: `string`):

Alias for a single-image run, kept so existing API callers and saved input configurations keep working. Pass one URL. Ignored when Images is filled in.

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

JPEG opens everywhere and is the right answer for photos. Choose PNG or WebP if the image has a transparent background you need to keep.

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

Compression quality from 1 to 100, used by JPEG, WebP and AVIF. 90 is visually indistinguishable from the original for most images. Ignored for PNG, TIFF and BMP, which are lossless.

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

What transparent areas become when the output format cannot store them, which is the case for JPEG and BMP. Accepts a colour name, a hex value such as #ffffff, or an rgb(255,255,255) triplet. Ignored when converting to PNG, WebP, AVIF or TIFF, which keep transparency as it was.

## `maxDimension` (type: `integer`):

Shrink the image so neither side exceeds this many pixels, keeping the aspect ratio. Leave empty to keep the original size. Images smaller than this are never enlarged.

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

Keeps the EXIF data, which includes the camera, the date the photo was taken and, on phone photos, the GPS location. Turn this off to strip it before sharing the file. The colour profile is kept either way.

## `stripToSRGB` (type: `boolean`):

Converts the image into the sRGB colour space and removes the embedded colour profile. Turn this on when a wide-gamut image (Display P3, Adobe RGB) looks oversaturated or washed out in a browser or an app that ignores colour profiles.

## `outputFilename` (type: `string`):

Name of the resulting file, without the extension. Defaults to the input filename. Applies to a single image only - in a batch it is ignored and each converted image keeps its own filename.

## `fileBase64` (type: `string`):

Alternative to the file field for API callers: a single source image encoded as base64. Adds about 33% to the payload size.

## `filename` (type: `string`):

Original filename to use when the file is passed as base64.

## `verboseLog` (type: `boolean`):

Includes the full ImageMagick output in the Actor log. Useful when a conversion produces odd output.

## Actor input object example

```json
{
  "outputFormat": "jpeg",
  "quality": 90,
  "backgroundColor": "white",
  "keepMetadata": true,
  "stripToSRGB": false,
  "verboseLog": false
}
```

# Actor output Schema

## `convertedImage` (type: `string`):

The run's primary result: the converted image for a single file, a ZIP of every converted image for a batch, or a JSON manifest naming them when the batch is too large to archive. This is the same record that the run-sync API endpoint returns in its HTTP response body.

## `allFiles` (type: `string`):

Every record in the run's key-value store: each converted image under its own filename, plus the ZIP or manifest when there was more than one input file.

## `conversionDetails` (type: `string`):

One record per input file, with an `ok` flag, the source format, dimensions, file sizes, transparency handling, download URL and, for a file that failed, the reason.

# 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 = {};

// Run the Actor and wait for it to finish
const run = await client.actor("marcel-rbro/png-to-jpg").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 = {}

# Run the Actor and wait for it to finish
run = client.actor("marcel-rbro/png-to-jpg").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 '{}' |
apify call marcel-rbro/png-to-jpg --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,marcel-rbro/png-to-jpg"
        }
    }
}

```

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/uirLbnJtcz3RYdAgf/builds/6OtI5uXK0ptKLbWgN/openapi.json
