How to create sticker images

Stickers are small background-less images that users can use, for example, to react in a conversation or to decorate their profile page:

The Photoroom API makes it easy to add this feature to your app.

Here's a before/after example of the kind of high-quality sticker the API can create:

There are two different ways to create a sticker through the Photoroom API, depending on whether the image you want to process is stored locally (in a file or a temporary variable) or hosted remotely.

Case 1: the orginal image is stored locally

If the image you want to process is stored locally, you can turn it into a sticker by calling our Remove Background API.

Here's how the call looks like:

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 'crop=true'
  --output sticker.png

If you don't have an API key, here are the steps to create yours.

Notice how, additionally to sending the image_file, we also set the argument crop=true.

As its name suggests, this argument crops the size of the result image to that of the cutout subject.

Case 2: the original image is hosted remotely

If the image you want to process is stored remotely, you can turn it into a sticker using the Image Editing API.

Here's how the call looks like:

curl --request GET \
  --url 'https://image-api.photoroom.com/v2/edit?background.color=transparent&background.scaling=fill&outputSize=croppedSubject&imageUrl=IMAGE_URL_GOES_HERE' \
  --header 'x-api-key: API_KEY_GOES_HERE' \
  --output sticker.png

If you don't have an API key, here are the steps to create yours.

Notice how the URL of the image is passed through the query string argument imageUrl.

This URL must be accessible publicly over the Internet.

Make sure to URL encode the value you set for the argument imageUrl.

Conclusion

As we’ve seen, the Photoroom API makes it easy to create high-quality stickers, whether the image that you want process is stored locally or remotely.

Please note that there's no difference in quality between the two approaches: both will yield the exact same cutout of the subject.

Last updated