Unable to use new CIRAWFilter API in iOS 15

I am unable to initialize a CIRAWFilter object and access its instance variables using the new CIRAWFilter class API in iOS 15.

If I compile and execute the following code, I get a run-time error stating, "-[CIRAWFilterImpl isGamutMappingEnabled]: unrecognized selector sent to instance 0x1065ec570'"

It appears that a "CIRAWFilterImpl" object is getting created, not a "CIRAWFilter" object. I cannot cast to that type as it is unknown (most likely a private class).

My code:

if #available(iOS 15.0, *) {

let rawFilter : CIRAWFilter = CIRAWFilter(imageURL: self.imageURL)

let isGamutMappingEnabled = rawFilter.isGamutMappingEnabled

print("isGamutMappingEnabled: (isGamutMappingEnabled)")

}

I have been running different tests with the new CiRawFilter class and it seems to work well for me on macOS 12.3.1 in a Playground in Xcode 13.3.1.

I tried the code with both a raw photo from my Canon Camera (CR2 format) and a raw photo from my iPhone 11 (DNG format). I do not have access to ProRaw photos, though.

BTW, I noticed that your rawFilter is not optional. Maybe this is the issue?

Here my code:

import Cocoa
import Foundation
import CoreImage
import SwiftUI

// Path to locally stored raw image, not ProRaw, from an iPhone 11
let rawimgpath = "/...path.../IMGAGE.dng"
let rawimgurl = URL(fileURLWithPath: rawimgpath)

// Initialising the CiRAWFilter with URL
let rawfilter = CIRAWFilter(imageURL: rawimgurl)

// Creating a CI Image
let rawimg = rawfilter?.outputImage

// Creating a CG Image
let context = CIContext()
let rawcgimg = context.createCGImage(rawimg!, from: rawimg!.extent)
let rawuiimg = Image(decorative: rawcgimg!, scale: 1.0)

// Printing the properties of the filter... this should also show your Gammut Mapping
let rawFltProps = rawfilter?.properties

// Printing the properties of the image... 
let rawImgProps = rawimg?.properties

// This does not cause an error
let isgammutMappingEnabled = rawfilter?.isGamutMappingEnabled // Returns (Optional)true

// Note: The Ci rawfilter is always optional with the "?" !

PS: Please, use the "Code Block" feature in the editor for better readability of your code. Makes things a little easier ;-).

BTW, this is a very good tutorial on raw image processing:

https://developer.apple.com/wwdc21/10160

Unable to use new CIRAWFilter API in iOS 15
 
 
Q