Scaled images upload (demo)
This mechanism allows uploading multiple scaled instances of original image. Following parameters should be used manage this feature:
shows whether scaled images should be uploaded. If true, uploaded file would be ZIP archive where entries are scaled images of original, entry count and names will match scaled instance names. ZIP file name is original file name + ".zip"
scaled instance names (comma separated, e.g. "small,medium,large")
scaled instance target box dimensions (comma separated, for example "100x100,200x200,400x400").
Each dimension also accepts scaling operators chain (separated by "-") at the end prepended with "x" separator (for example 100x100xop1-op2...opN). Operator could be one of:
- fit (default if nothing specified) — scale image to maximum size that fits in the box;
- cover — scale imageto minimum size that covers the box;
- crop — center image in the box and crop image margins that doesn't fit in the box;
- rotate — rotate image 90 degrees if image orientation doesn't match box orientation.
- trim (since 2.17.3)—trims margins of solid colors from image.
- IUploadFile — the file of image being scaled
- String — the name of scaled instance
scaled instance quality factors (0-worse quality, 1000-best), (comma spearated, for example, "900,800,700"
- scaledInstanceScaleMode (since 2.15.0)
scale mode for scaled images, this could be one or multiple (comma separated) value(s) from list:
smooth, fast, bilinear, lanczos (default), for example, "lanczos,smooth,fast"
Sample image scaled using different methods:
Scaled image watermarking
This is an extension of "scaled images upload" feature.
In order to apply watermarks to scaled images, use scaledInstanceWatermarkNames
parameter to specify watermark names for scaled instances, use "null" to specify that
watermark should not be applied for specified instance or arbitrary name for watewrmark, for example:
Every name specified in parameter value must be parameter name for
watermark properties, for example:
<param name="mediumWm" value="halign=center;valign=middle;opacityPercent=20;imageUrl=wmMedium.png"/>
Parameter value is ";" separated list of key=value pairs, keys are:
- halign: horizontal alignment (left/center/right)
- valign: vertical alignment (top/middle/bottom)
- opacityPercent: opacity 0 (transparent)..100 (opaque)
- imageUrl: image URL (absolute or relative to document base)
scaledInstancePreserveMetadata ("false" by default) parameter allows writing original image metadata (EXIF, IPTC) to scaled image. Value should be comma separated boolean value(s) (true, false), one per scaled instance. If number of tokens is smaller than number of scaled instances, last token used for missed entries. For example, if scaledInstanceNames="small,medium,large" and scaledInstancePreserveMetadata="true", metadata will be written to all the scaled images.
Metadata writing feature powered by Sanselan. It is necessary to specify additional sanselan_z.jar for applet tag:
<applet id="jumpLoaderApplet" name="jumpLoaderApplet" code="jmaster.jumploader.app.JumpLoaderApplet.class" archive="jumploader_z.jar,sanselan_z.jar">
sanselan_z.jar available in the download section.
Since applet limited in system memory consumption (generally about 100M), jumploader may fail to load large images for scaling. There are options to prevent such a failure:
- Subsampling — load image each N'th pixel, if it is too big. This feature is controlled by UploaderConfig.imageSubsamplingFactor parameter (default=7) — subsampling (S) (for both x and y axis) calculated with formula S = 1 + MPX / SF, where MPX is number of image megapixels (rounded). Read here about image subsampling: http://java.sun.com/j2se/1.4.2/docs/api/javax/imageio/IIOParam.html#setSourceSubsampling(int, int, int, int)
However it's downside is that it only works when the image is scaled down to at least 50% of its length and width (which is the default case in most of the time with high-res pictures). For example, if original image is 3000x3000 (9Mpx), then subsampling factor for that would be 1+9/7=2, so loaded image would be 1500x1500. And if scaled image box is, lets say, 2000x2000, resoult image would be 1500x1500 (if not stretched)
- Scale regions — load image by regions and scale each region to target image. This feature controlled by parameters:
UploaderConfig.imageLoadPixelsMax — the maximum size of image (pixels) to load (default=7000000). If image is larger, this would be scaled by regions.
UploaderConfig.regionPixelsMax — the maximum size (pixels) of region to use for image scaling by regions (default=3000000).