feat: Add support for creating Cutout Stickers #2342
+111
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR adds support for the Cutout Sticker creation feature (converting photos to stickers in Direct Messages).
It implements the logic found in the latest Instagram versions, allowing users to create native stickers that are saved to the user's sticker tray.
Features
Changes
instagrapi/mixins/media.py: Addedmedia_configure_to_cutout_sticker. This handles the private API endpointmedia/configure_to_cutout_sticker/.instagrapi/mixins/photo.py: Addedphoto_upload_to_cutout_sticker. A high-level helper that uploads a photo and configures it as a sticker in one step.Reverse Engineering Notes
I reverse-engineered this flow by patching the Instagram Android APK to inject logging into the networking classes (
LX/UtPandLX/WLA).The key discovery was that the
media/upload_edit/endpoint (used for AI segmentation) can be completely bypassed by providing amanual_maskwith a full bounding box ([0.0, 0.0, 1.0, 1.0]) directly to the configuration endpoint. This results in acustom_stickerproduct type withstatus: ok.Usage Example