How to define options for CIFIlter?

When creating a raw image with CIFilter, I need to provide and identifier hint for the raw image decoder. How do I do this?

The following code does not populate the dictionary and CIFilter returns nil.

How would I do this correctly? I am completely stuck.

Code Block
let rfo = [ String(kCGImageSourceTypeIdentifierHint) : "com.sony.raw-image" ] as! [CIRAWFilterOption:Any]
let cii = CIFilter(imageData: data , options: rfo).outputImage

Answered by OOPer in 661959022
Are you sure kCGImageSourceTypeIdentifierHint is the right key for your purpose?
The doc of kCGImageSourceTypeIdentifierHint says This key can be provided in the options dictionary when you create a CGImageSource object, no mention about CIFilter.
At least, the key needs to be of type CIRAWFilterOption, not String.
Code Block
let sourceTypeIdentifierHint = CIRAWFilterOption(rawValue: kCGImageSourceTypeIdentifierHint as String)
let rfo: [CIRAWFilterOption: Any] = [
sourceTypeIdentifierHint : "com.sony.raw-image"
]


Accepted Answer
Are you sure kCGImageSourceTypeIdentifierHint is the right key for your purpose?
The doc of kCGImageSourceTypeIdentifierHint says This key can be provided in the options dictionary when you create a CGImageSource object, no mention about CIFilter.
At least, the key needs to be of type CIRAWFilterOption, not String.
Code Block
let sourceTypeIdentifierHint = CIRAWFilterOption(rawValue: kCGImageSourceTypeIdentifierHint as String)
let rfo: [CIRAWFilterOption: Any] = [
sourceTypeIdentifierHint : "com.sony.raw-image"
]


Thank you for explaining the syntax. Excellent!

Good point about CGImageSourceOption. According to the CIFilter initializer, it is recommended to provide this option.

I will test this later today.

According to the CIFilter initializer, it is recommended to provide this option.  

Thanks. I was missing that part.
How to define options for CIFIlter?
 
 
Q