PESDK/iOS/Guides
Background Removal
PhotoEditor SDK combined with Apple ML Vision framework allows to quickly remove the background from pictures of people on iOS 15+ devices.
The remove background
action is available for any pictures or (non-animated) personal and external stickers, where a face or human body can be detected:
This effect can be used to create transparent stickers, avatars, or collages:
WARNING: The background removal overlay action does not work properly on the simulator. To see background properly removed please use this action on the physical device.
Adding background removal option#
✨Introduced in PhotoEditor SDK v11.1.0
To enable background removal, edit allowedMediaEditOverlayActions
configuration property:
let configuration = Configuration { builder inbuilder.configurePhotoEditViewController { options inif #available(iOS 15.0, *) {options.allowedMediaEditOverlayActions.append(.removeBackground)}options.outputImageFileFormat = .png}}let sampleImage = UIImage(named: "sample_image")!let photo = Photo(image: sampleImage)let photoEditViewController = PhotoEditViewController(photoAsset: photo, configuration: configuration)
WARNING: To achieve the effect of transparency in exported images, make sure that your output format supports that (e.g. set
outputImageFileFormat
to.png
).