If you work on a social app, you know how important it is to deliver an experience that keeps your users engaged and excited over time.
A great way to deliver such an experience is to allow your users to personalize the way they interact with your app.
And that’s when stickers come into play!
Stickers are small background-less images that users can use, for example, to react in a conversation or to decorate their profile page:
But what’s really great with stickers is that you can enable your users to create their own personalized ones, which will allow them to bring a lot of their personality into your app!
Popular social apps such as Mojo and Id by amo actually use the Photoroom API in order to offer this personalized stickers feature to their users.
So let’s see how the Photoroom API will help you add this feature to your app.
How to create stickers with the Photoroom API
From a technical point of view, turning a regular image into a sticker is a two-step process:
first, cutting out the main subject of the original image
then, cropping the result image to the bounds of that main subject
Fortunately, the Photoroom API takes care of both steps in a single call!
To implement this, we’re going to use Photoroom’s Remove Background API.
Here’s how a call to this API 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
To make the call, you will need an API key. Here are the steps to get your API key.
And here's a before/after example of a call to this API:
The API call is made through a POST HTTP request, which takes three arguments:
x-api-key is your Photoroom API key
image_file is the file containing the image to use to create the sticker
crop=true tells the API to crop the result image to the bounds of the cutout subject
As you can see, it’s just a standard HTTP call that uses multipart formatting to send its data.
This means that integrating the API call into your codebase should be fairly straightforward.
We’ve even written wrappers to help you seamlessly integrate the API into Web, Node.js, Python, and iOS projects.
Conclusion
That’s it, thanks to the Photoroom API we’ve seen that you can easily enable your users to create high-quality stickers that they’ll be able to use inside your social app.
For more details about all that can be achieved using Photoroom’s API, check out this page on our website!