File size, resolution and format
Which image formats are supported?
For the input image, the Remove Background API supports four formats: PNG, JPEG, WEBP and HEIC.
For the result image, the Remove Background API supports three formats: PNG, JPEG and WEBP.
By default, the result image will be in PNG format.
To configure the format of the result image, set the argument format with one of the following values:
pngfor PNG format (bigger file size, transparency is saved)jpgfor JPEG format (smaller file size, transparency is not saved)webpfor WEBP format (smaller file size, transparency is saved)
If you want to give it a try, here's the code to export an image in JPEG format:
curl --request POST \
--url https://sdk.photoroom.com/v1/segment \
--header 'x-api-key: YOUR_API_KEY' \
--form image_file=@/absolute/path/to/image.jpg \
--form format=jpg \
--output photoroom-result.jpgAnd here's the code to export an image in WEBP format:
curl --request POST \
--url https://sdk.photoroom.com/v1/segment \
--header 'x-api-key: YOUR_API_KEY' \
--form image_file=@/absolute/path/to/image.jpg \
--form format=webp \
--output photoroom-result.webpWhat is the max resolution of the image?
We recommend limiting images to 25 megapixels for optimal performance.
Maximum File Size: 50MB
Maximum Resolution: 6,000 pixels on the widest side
Can I use the URL of an image?
The Remove Background API requires you to upload the content of your image file when making the API call.
However, if your images are already hosted online, it's possible that you don't have the image file itself, but rather a URL that points to the file.
If that's the case, there are two solutions for you to process your image through the Photoroom API.
Option 1: Download the image locally
In most situations, you should be able to use the image URL to download the content of the image, store it in a local variable, and then use it when calling the Remove Background API.
Here's an example code in JavaScript of how to implement this workflow:
Option 2: Use the Image Editing API
If downloading the content of the image in a local variable is absolutely not possible for you, then you can use our Image Editing API to process your images.
The Image Editing API does offer a GET endpoint, thanks to which you can use the argument imageUrl to pass the URL of your image.
Last updated
Was this helpful?