Post

Replies

Boosts

Views

Activity

App crashes while trying to save CIImage after applying CIFilter
Hi,I hope somebody is able to help me.I am loading 2 DNG files from the apps documents folder using a CIFilter. That is working fine.After that I combine these images using a CIMaximumCompositing CIFilter.When I now try to save the outputImage to a JPEG file, my app crashes with the following output. (On line 19)Message from debugger: Terminated due to memory issueWhen I try to save the 2 loaded DNG files without any processing everything is working fine too.Here is my Code: private func process() { let raw_path_1 : String = _current_scan._path.path + "/raw/line_0_0.dng" let raw_filter_1 : CIFilter = CIFilter( imageURL: URL(fileURLWithPath: raw_path_1), options: nil ) let raw_image_1 : CIImage = raw_filter_1.outputImage! let raw_path_2 : String = _current_scan._path.path + "/raw/line_1_0.dng" let raw_filter_2 : CIFilter = CIFilter( imageURL: URL(fileURLWithPath: raw_path_2), options: nil ) let raw_image_2 : CIImage = raw_filter_2.outputImage! let result_image : CIImage = raw_image_1.applyingFilter( "CIMaximumCompositing", parameters: [kCIInputBackgroundImageKey: raw_image_2] ) let result_path : String = _current_scan._path.path + "/raw/line_0.jpeg" if let colorSpace = CGColorSpace(name: CGColorSpace.sRGB) { do { let context = CIContext() try context.writeJPEGRepresentation( of: result_image, to: URL(fileURLWithPath: result_path), colorSpace: colorSpace, options: [kCGImageDestinationLossyCompressionQuality as CIImageRepresentationOption : 1.0] ) } catch { print( error.localizedDescription ) } } }Thank you all!
4
0
1.7k
Dec ’19