... | ... | @@ -4,20 +4,117 @@ |
|
|
|
|
|
### Tracking down errors
|
|
|
|
|
|
When something goes wrong with the interpretation of the json or plist data when creating or rendering a image filter chain object then smig will often return a terse error message. When this happens it is likely that there will be useful information in MovingImages' log file. The [Introduction to using MovingImages debugging section describes how to view the log file](UsingMovingImages#debugging)
|
|
|
When something goes wrong with the interpretation of the json or plist data when creating or rendering a image filter chain object then smig will often return a terse error message. When this happens it is likely that there will be useful information in MovingImages' log file. The [Introduction to using MovingImages debugging section describes how to view the log file](UsingMovingImages#debugging).
|
|
|
|
|
|
### Creating an Image Filter Chain object
|
|
|
### Getting a list of the CoreImage filters
|
|
|
|
|
|
#### Getting a list of the CoreImage filters
|
|
|
To get a list of all the available CoreImage filters:
|
|
|
|
|
|
#### Getting the attributes of a CoreImage filter
|
|
|
smig getproperty -type imagefilterchain -property imagefilters
|
|
|
|
|
|
#### Chaining filters together
|
|
|
To get the list of filters that belong to particular category:
|
|
|
|
|
|
#### Providing images from image importer and bitmap context objects
|
|
|
smig getproperty -type imagefilterchain -property imagefilters -filtercategory CICategoryDistortionEffect
|
|
|
|
|
|
All the filters belong to more than one category. The list of categories, from Apple's documentation are:
|
|
|
|
|
|
CICategoryBlur
|
|
|
CICategoryColorAdjustment
|
|
|
CICategoryCompositeOperation
|
|
|
CICategoryDistortionEffect
|
|
|
CICategoryGenerator
|
|
|
CICategoryGeometryAdjustment
|
|
|
CICategoryGradient
|
|
|
CICategoryHalftoneEffect
|
|
|
CICategorySharpen
|
|
|
CICategoryStylyize
|
|
|
CICategoryTileEffect
|
|
|
CICategoryTransition
|
|
|
|
|
|
### Getting the attributes of a CoreImage filter
|
|
|
|
|
|
To be able to create a property list or a json object that you can setup a core image filter in a filter chain, you need to know what the keys are for the filter that can be set, and what their expected range is. To get that information about a filter you can request "imagefilterattribute" property from the "imagefilterchain" type. The information can be returned in one of 3 ways. Either as a json string (see the example below) or saved to a json or a plist file (-jsonfile, -plistfile). If saving to a file then after the (-jsonfile, -plistfile) option you need to provide a file path.
|
|
|
|
|
|
The following shows you how to get the properties about the CIDroste filter as a json string.
|
|
|
|
|
|
smig getproperty -type imagefilterchain -property imagefilterattributes -filtername CIDroste -jsonstring
|
|
|
|
|
|
This returns the non human friendly version of the json string. To quickly view the human friendly version, copy the result and paste it into either: [JSONLint](http://jsonlint.com) or [JSON Editor online](http://jsoneditoronline.org).
|
|
|
|
|
|
### Setting up the properties for a filter
|
|
|
|
|
|
All but a few of the core image filters require inputs. All the numerical inputs for the filters have default values that means for a quick and dirty test of a filter you don't need to assign these values. Other input types like images, require an input as they don't have a default, and input types like CIVector and CIColor have default values, but the default values really need to be overridden.
|
|
|
|
|
|
Each filter in a filter chain, is described by the filter name, a render destination, a name identifier and a list of properties to be assigned. The filter name is the core image name of the filter to be created, and the name identifier is used to chain together filters in a filter chain. Filters later in the chain can reference earlier filters by their name identifier and assign any of their input images to the output image of an earlier filter.
|
|
|
|
|
|
{
|
|
|
"cifiltername": "CIUnsharpMask",
|
|
|
"mifiltername" : "com.yvs.renderingfilterchain.example.unsharpmask"
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputRadius",
|
|
|
"cifiltervalue": 2.5
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputIntensity",
|
|
|
"cifiltervalue": 1.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputImage",
|
|
|
"cifiltervalueclass": "CIImage",
|
|
|
"cifiltervalue": {
|
|
|
"objectreference": 0
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
In the above json example, the core image filter to be created is a Core Image Unsharp Mask filter. The filter is given the identifier "com.yvs.renderingfilterchain.example.unsharpmask" and the filter takes three inputs. These are the input radius, which takes a numeric value, input intensity which also takes a numeric value the input image which of course takes an image.
|
|
|
|
|
|
When an input is an image, then the input value is a way to identify the image and is a json object. The image can be sourced as the output image of a previous filter in the filter chain and if that was the case then the key in the object would be "mifiltername" and the value would be a string which is the name identifier. If the image is sourced from a bitmap context then the key in the object would be "objectreference" as in the above example which refers to a base object with reference 0. The image can also come from an image importer object in which case the "objectreference" key is also used but that a "imageindex" key should also be supplied specifying the index of the image in the image file. If "imageindex" is not specified and the object reference refers to an image importer object then "imageindex" defaults to 0.
|
|
|
|
|
|
When a filter takes a numeric input, it is not necessary to specify the "cifiltervalueclass" but for all other input types specifying the value class is required and in the above example "CIImage" is demonstrated. Other "cifiltervalueclass" keys are "CIVector", "CIColor", "NSString". In the case of both CIVector and CIColor the actual type for the key "cifiltervalue" is a string, the purpose of the "cifiltervalueclass" key is to inform Moving Images what object type the string needs to be converted into before it can be assigned to the filter.
|
|
|
|
|
|
In the following example the json object represents the information needed for creating a Core Image Radial Gradient filter. It demonstrates the defining of filter inputs with value class "CIVector" and "CIColor". The format of the strings defining these object needs to be kept to strictly. In this example the the centre of the radial gradient is specified as a coordinate pair of two numbers, x and y. For specifying a color the string format is slightly different with no square brackets. Each color is specified by 4 numbers representing the three color components and the alpha value: Red Green Blue Alpha. The input "inputColor0" is assigned a white opaque color while "inputColor1" is assigned a black opaque color.
|
|
|
|
|
|
{
|
|
|
"cifiltername": "CIRadialGradient",
|
|
|
"mifiltername": "com.yvs.renderingfilterchain.example.radialfilter",
|
|
|
"cifilterproperties": [
|
|
|
{
|
|
|
"cifilterkey": "inputCenter",
|
|
|
"cifiltervalueclass": "CIVector",
|
|
|
"cifiltervalue": "[200.0 200.0]"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius0",
|
|
|
"cifiltervalue": 10.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputRadius1",
|
|
|
"cifiltervalue": 200.0
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputColor0",
|
|
|
"cifiltervalueclass": "CIColor",
|
|
|
"cifiltervalue": "1 1 1 1"
|
|
|
},
|
|
|
{
|
|
|
"cifilterkey": "inputColor1",
|
|
|
"cifiltervalueclass": "CIColor",
|
|
|
"cifiltervalue": "0 0 0 1"
|
|
|
}
|
|
|
]
|
|
|
}
|
|
|
|
|
|
### Chaining filters together
|
|
|
|
|
|
### Providing images from image importer and bitmap context objects
|
|
|
|
|
|
### Rendering an Image Filter Chain object
|
|
|
|
|
|
At present the only object type that can be a render destination is the object type "bitmapcontext". This will change.
|
|
|
|
|
|
### The Image Filter Chain ruby processing scripts
|
|
|
|
|
|
### The YVSChromaKey filter
|
... | ... | |