File size, resolution and format
Which image formats are supported?
For the input and result images, the Image Editing API supports four formats: PNG, JPEG, WEBP and AVIF.
By default, the result image will be in PNG format.
To configure the format of the result image, set the argument export.format with one of the following values:
pngis the lossless PNG format (biggest file size, zero quality loss, transparency is saved)jpegorjpgfor JPEG format (smaller file size, transparency is not saved)webpfor WebP format (even smaller file size, transparency is saved)aviffor AVIF format (smallest file size, takes a few seconds longer to create, transparency is saved)
JPEG format does not support transparency.
Asking the Image Editing API to export in JPEG while also setting a background color with transparency will result in an error.
If you want to give it a try, here's the code to export an image in JPEG format:
curl --request POST \
--url https://image-api.photoroom.com/v2/edit \
--header 'x-api-key: YOUR_API_KEY' \
--form imageFile=@/path/to/your/image.jpg \
--form background.color=FFFFFF \
--form outputSize=1000x1000 \
--form padding=0.1 \
--form 'export.format=jpeg' \
--output result.jpegAnd here's the code to export an image in WebP format:
And the code to export an image in AVIF format:
Preserving the input colour space (colorSpace: "original")
By default the Image Editing API returns results in sRGB. Set colorSpace: "original" on /v2/edit to keep the input image's own colour space and embedded ICC profile (e.g. Adobe RGB, Display P3) in the output — preserved with no conversion to sRGB. This applies to background removal (including HD): the cutout is returned as a PNG carrying the original ICC profile.
Default (omit
colorSpace, orcolorSpace=sRGB): output is sRGB, exactly as before.colorSpace=original: output keeps the input's colour space + ICC profile.
When it works
A pure background removal (no other edits), with PNG output, on an input that has an embedded colour profile.
When it returns HTTP 400
colorSpace: "original" only applies to a plain background removal that outputs PNG. The request is rejected with a 400 (the error names the conflicting parameter) if it also includes:
Any operation beyond background removal — AI/replacement backgrounds, a background colour or image, shadows, relighting, templates, etc.
An output format other than PNG (e.g. JPG, WebP, AVIF).
export.dpi.keepExistingAlphaChannelset to anything other thannever.preserveMetadataset to an EXIF-subset mode.
What are the max resolution and size of the image?
We recommend limiting images to 25 megapixels for optimal performance.
Maximum File Size: 30MB
Maximum Resolution: 5,000 pixels on the widest side
Images with a larger resolution are supported (if they stay below 30MB), but will be resized down to 5,000 pixels on the widest side.
Last updated
Was this helpful?