Filter Chains

JMAGE supports more complex operations through filter chains. This invokes several filters sequentially and pipes the results of one operation as input into to the next one. The current implementation lets you do this, by specifying the order of filters and their parameters in an xml file that gets deserialized into a org.jmage.filterchain.FilterChain at runtime.

Include the xml file into a /xml folder inside your web application, or specify an external path using the JMAGE.RESOURCE.DIR property in jmage.xml. You can invoke any filterchain by it's resource name. If you want to organize your filters in folders, simply append their names a java 'packages' before the filter name, i.e /xml/com/mycorp/MyFilterChain.xml will be accessible as com.mycorp.MyFilterChain

FilterChains naturally take longer to execute, so you may want to set up your cache accordingly. Lets have a look at an example filter chain.


<?xml version="1.0" encoding="ISO-8859-1" standalone="yes"?>
<filterchain name="org.jmage.filterchain.thumbnail.Thumbnail">
    <filter name="org.jmage.filter.spatial.GaussianBlurFilter"/>

    <filter name="org.jmage.filter.size.BicubicResizeFilter">
        <property name="WIDTH" value="100"/>
        <property name="HEIGHT" value="133"/>
    </filter>

    <filter name="org.jmage.filter.size.BorderExtenderFilter">
        <property name="BORDER" value="1"/>
        <property name="COLOR" value="666666"/>
    </filter>

    <filter name="org.jmage.filter.spatial.UnsharpMaskFilter"/>
</filterchain>

This is pretty much self explanatory. Filters and their properties are listed in an ordered fashion. The top filter is going the be invoked first and it's results end up being 'input material' for the second one. You can choose any amount or order of filters you want, but bear in mind that running more than 5 at any one time will probably be slowing down your app, so use with care and make sure your hardware acceleration is set up properly.