Please note that PhotoRoomKit
has been deprecated.
For an up-to-date code sample, please check out: https://github.com/PhotoRoom/api-code-samples/
PhotoRoomKit is a fast background removal API. Power your app with the background removal technology used by millions of sellers every month.
PhotoRoomKit is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'PhotoRoomKit'
PhotoRoomKit is also available through Carthage. To install just write into your Cartfile:
github "PhotoRoom/PhotoRoomKit"
PhotoRoomKit can also be installed manually. Just download and drop Sources
folders in your project.
First you will need an API Key, go to our API website to get your own PhotoRoom key.
Then, you can either use the provided PhotoRoomViewController
, or use the API wrapper
Just present PhotoRoomViewController
and handle the callback
func removeBackground(_ originalImage: UIImage) {
let controller = PhotoRoomViewController(image: originalImage,
apiKey: 'YOUR_API_KEY') { [weak self] image in
self?.onImageEdited(image)
}
present(controller, animated: true)
}
func onImageEdited(_ editedImage: UIImage) {
// Handle your segmented image
}
When using the built-in view controller, Photoroom attribution is done for you, no need for extra work.
You can also use the API wrapper directly.
let segmentationService = SegmentationService(apiKey: apiKey)
segmentationService.segment(image: originalImage) { (image, error) in
DispatchQueue.main.async {
if let error = error {
// An error occured
}
guard let image = image else {
// No image returned
return
}
// All good
}
}
PhotoRoom, [email protected]
We would love you to contribute to PhotoRoomKit, check the CONTRIBUTING file for more info.
PhotoRoomKit is available under the MIT license. See the LICENSE file for more info.