Guest User

Untitled

a guest
Oct 15th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. func portraitEffectsMatteImageAt(_ path: String) -> UIImage? {
  2. let bundlePath = Bundle.main.bundlePath
  3.  
  4. // Check that the image at given path contains auxiliary PEM data:
  5. guard let fileURL = NSURL(fileURLWithPath: bundlePath).appendingPathComponent(path),
  6. let source = CGImageSourceCreateWithURL(fileURL as CFURL, nil),
  7. let auxiliaryInfoDict = CGImageSourceCopyAuxiliaryDataInfoAtIndex(source, 0, kCGImageAuxiliaryDataTypePortraitEffectsMatte) as? [AnyHashable: Any],
  8. let matteData = try? AVPortraitEffectsMatte(fromDictionaryRepresentation: auxiliaryInfoDict),
  9. let matteCIImage = CIImage(portaitEffectsMatte: matteData)
  10. else {
  11. return nil
  12. }
  13. return UIImage(ciImage: matteCIImage)
  14. }
  15.  
  16. guard let fileURL = Bundle.main.url(forResource: "custom00", withExtension: "jpg")
Add Comment
Please, Sign In to add comment