What to do if Core Image is ignoring your slider attributes
So you’re writing an Image Unit, and it has a couple of numeric parameters. You expect that Core Image Fun House will show a slider for each of them, and it does—but no matter what you do, the slider’s minimum and maximum are both 0. Furthermore, Core Image Fun House doesn’t show your parameters’ real display names; it simply makes them up from the parameters’ KVC keys.
The problem is that you are specifying those attributes in the wrong place in your Description.plist. And yes, I know you’re specifying them where the project template had them—so was I. The template has it wrong.
One of the filter attributes that Core Image recognizes is CIInputs
. The value for this key is an array of dictionaries; each dictionary represents one parameter to the filter. The template has all the parameter attributes in these dictionaries. That makes sense, but it’s not where Core Image looks for them.
In reality, Core Image only looks for three keys in those dictionaries:
CIAttributeName
CIAttributeClass
CIAttributeDefault
Anything else, it simply ignores.
The correct place to put all those other keys (including CIAttributeSliderMin
, CIAttributeSliderMax
, and CIAttributeDisplayName
) is in another dictionary—one for each parameter. These dictionaries go inside the CIFilterAttributes
dictionary. In other words, the CIFilterAttributes
dictionary should contain:
CIInputs
=> Aforementioned array of (now very small) dictionariesinputFoo
=> Dictionary fully describing theinputFoo
parameter, including slider attributes and display nameinputBar
=> Dictionary fully describing theinputBar
parameter, including slider attributes and display nameinputBaz
=> Dictionary fully describing theinputBaz
parameter, including slider attributes and display name
Finally, an example:
<key>CIFilterAttributes</key> <dict> ⋮ <key>CIInputs</key> <array> <dict> <key>CIAttributeClass</key> <string>CIImage</string> <key>CIAttributeName</key> <string>inputImage</string> </dict> <dict> <key>CIAttributeClass</key> <string>NSNumber</string> <key>CIAttributeDefault</key> <real>1.0</real> <key>CIAttributeName</key> <string>inputWhitePoint</string> </dict> <dict> <key>CIAttributeClass</key> <string>NSNumber</string> <key>CIAttributeDefault</key> <real>0.0</real> <key>CIAttributeName</key> <string>inputBlackPoint</string> </dict> </array> <key>inputWhitePoint</key> <dict> <key>CIAttributeClass</key> <string>NSNumber</string> <key>CIAttributeDefault</key> <real>1.0</real> <key>CIAttributeDisplayName</key> <string>White point</string> <key>CIAttributeIdentity</key> <real>1.0</real> <key>CIAttributeMin</key> <real>0.0</real> <key>CIAttributeMax</key> <real>1.0</real> <key>CIAttributeName</key> <string>inputWhitePoint</string> <key>CIAttributeSliderMin</key> <real>0.0</real> <key>CIAttributeSliderMax</key> <real>1.0</real> <key>CIAttributeType</key> <string>CIAttributeTypeScalar</string> </dict> <key>inputBlackPoint</key> <dict> <key>CIAttributeClass</key> <string>NSNumber</string> <key>CIAttributeDefault</key> <real>0.0</real> <key>CIAttributeDisplayName</key> <string>Black point</string> <key>CIAttributeIdentity</key> <real>0.0</real> <key>CIAttributeMin</key> <real>0.0</real> <key>CIAttributeMax</key> <real>1.0</real> <key>CIAttributeName</key> <string>inputBlackPoint</string> <key>CIAttributeSliderMin</key> <real>0.0</real> <key>CIAttributeSliderMax</key> <real>1.0</real> <key>CIAttributeType</key> <string>CIAttributeTypeScalar</string> </dict> </dict>
You can see how the descriptions under CIInputs
are as terse as possible; everything besides the absolute necessities is specified in the outer dictionaries.
March 1st, 2008 at 14:35:26
Which template exactly has the incorrect plist?
March 1st, 2008 at 21:21:37
Blake C.: The Image Unit template.
August 31st, 2010 at 10:03:37
That you, Peter.
I found this post in my websearch for a problem that looks similar, involving executable kernels. I am posting a follow-up to help anyone who stumbles across this set of problems (spent a day hitting my head against the wall).
To get your properties to show up in Core Image Fun House, CI Filter Browser, etc, etc, you must also conform to some naming conventions (not sure if these come from AppKit, UIKit, or whatever):
Instead of:
minimum
saturationValue
weatherControlFactor
…etc.
use:
inputMinimum
inputSaturationValue
inputWeatherControlFactor
Voila! They suddenly show up.
Hope this helps someone,
Cheers,
David
August 31st, 2010 at 19:31:17
David Kim: That convention is enforced by either Core Image or Core Image Fun House; I don’t know which. It is not part of Cocoa, and is certainly not part of Cocoa Touch, which doesn’t have Core Image.