Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func portraitEffectsMatteImageAt(_ path: String) -> UIImage? {
- let bundlePath = Bundle.main.bundlePath
- // Check that the image at given path contains auxiliary PEM data:
- guard let fileURL = NSURL(fileURLWithPath: bundlePath).appendingPathComponent(path),
- let source = CGImageSourceCreateWithURL(fileURL as CFURL, nil),
- let auxiliaryInfoDict = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypePortraitEffectsMatte) as? [AnyHashable: Any],
- let matteData = try? AVPortraitEffectsMatte(fromDictionaryRepresentation: auxiliaryInfoDict),
- let matteCIImage = CIImage(portaitEffectsMatte: matteData)
- else {
- return nil
- }
- return UIImage(ciImage: matteCIImage)
- }
- guard let fileURL = Bundle.main.url(forResource: "custom00", withExtension: "jpg")
Add Comment
Please, Sign In to add comment