We assume you want to generate and upload two thumbnails for each image. You will need to define two filters. Let's call "medium" the one that scales images to 640x480 and "small" the one that scales images to 160x120.
First, starting from your existing JFileUpload + JImageFilter installation, you need to create two scaling properties files with the target dimensions.
scaling_medium.properties:
maxwidth=640
maxheight=480
...
scaling_small.properties:
maxwidth=160
maxheight=120
...
Second, you need to declare the two filters in applet javascript file:
...
<PARAM NAME="resources" VALUE="i18n">
<PARAM NAME="additionalfilterid" VALUE="medium,small">
<PARAM NAME="mediumfilter" VALUE="jfileupload.upload.client.filter.ImageFilter">
<PARAM NAME="mediumfilterproperties" VALUE="scaling_medium.properties">
<PARAM NAME="smallfilter" VALUE="jfileupload.upload.client.filter.ImageFilter">
<PARAM NAME="smallfilterproperties" VALUE="scaling_small.properties">
Finally, you need to setup a custom rename policy to avoid file overwrite:
<PARAM NAME="mediumfilterparam2" VALUE="renamepolicy">
<PARAM NAME="mediumfiltervalue2" VALUE="custom">
<PARAM NAME="mediumfilterparam3" VALUE="id">
<PARAM NAME="mediumfiltervalue3" VALUE="thumb_640_480_">
<PARAM NAME="smallfilterparam2" VALUE="renamepolicy">
<PARAM NAME="smallfiltervalue2" VALUE="custom">
<PARAM NAME="smallfilterparam3" VALUE="id">
<PARAM NAME="smallfiltervalue3" VALUE="thumb_160_120_">
The applet will create a thumbnail according to each filter and upload them with a filename such as: idvalue_imagelfilename.jpeg
Notice that you can also setup different quality and/or algorithm for each thumbnail because there are two scaling filter independant instances.
The applet will upload the medium thumbnails first because the "additionalfilterid" parameter declares medium filter first. |
|
You can now add more than two thumbnails by declaring a new filter with an unique identifier. Notice that "preprocessing" identifier is reserved and must not be used.
|
JImageFilter includes a Meta Filter that allows to apply custom rename policy without scaling the image. Starting from the sample above, you need the default scaling.properties installed and the following parameters:
...
<PARAM NAME="resources" VALUE="i18n">
<PARAM NAME="additionalfilterid" VALUE="medium,small,orig">
...
<PARAM NAME="origfilter" VALUE="jfileupload.upload.client.filter.MetaFilter">
<PARAM NAME="origfilterproperties" VALUE="scaling.properties">
<PARAM NAME="origfilterparam2" VALUE="renamepolicy">
<PARAM NAME="origfiltervalue2" VALUE="custom">
<PARAM NAME="origfilterparam3" VALUE="id">
<PARAM NAME="origfiltervalue3" VALUE="original_">
The original image will be uploaded as original_imagefilename.jpeg.
|