PNG/JPEG representation from CIImage always returns nil

Just begin a new graphics context and draw your grayscale image there. iOS 10 or later you can use UIGraphicsImageRenderer, for older iOS version syntax please check edit history: Xcode 11 • Swift 5.1 func blackWhiteImage(image: UIImage, isOpaque: Bool = false) -> Data? { guard let ciImage = CIImage(image: image)?.applyingFilter(“CIColorControls”, parameters: [kCIInputSaturationKey: 0]) else { … Read more