OpenCms JSP standard taglib
Tag scaleImage


This tag allows flexible creation of scaled images using the OpenCms native image scaling mechanism. It generates an image bean that can render scaled versions of the selected image, adding the required image scaling parameters.

The following image formats are supported: BMP, GIF, JPEG, PNG, PNM, TIFF. Note: Picture scaling is by default only enabled for target size with width and height <=1500. The size can be changed in the image scaler configuration in the file opencms-vfs.xml in the body of the tag <loader>. Also other options for the image scaler are set there.

This tag is an alternative to the cms:img tag, providing more flexibility by not generating any output but providing a bean that may be used to generate any output needed. This way you can use scaled images for


Tag Information
Tag Classorg.opencms.jsp.CmsJspTagScaleImage
TagExtraInfo ClassNone
Body ContentJSP
Display NameNone

Attributes
NameRequiredRequest-timeTypeDescription
srcfalsetruejava.lang.StringURI of the image's source file.

Note: The uri will be adjusted by OpenCms automatically, so do not use <cms:link>.
widthfalsetruejava.lang.StringA natural number specifying the target width
heightfalsetruejava.lang.StringA natural number specifying the target height
maxWidthfalsetruejava.lang.StringDeprecated

A natural number specifying the maximal width of an image scaled with scaleType="5".
For other scale types the attribute is ignored.
maxHeightfalsetruejava.lang.StringDeprecated

A natural number specifying the maximal height of an image scaled with scaleType="5".
For other scale types the attribute is ignored.
scaleTypefalsetruejava.lang.StringSet the scale type used for the image.
Possible values are:
0 (default): Scale to exact target size with background padding
  • enlarge image to fit in target size (if required)
  • reduce image to fit in target size (if required)
  • keep image aspect ratio / proportions intact
  • fill up with bgcolor to reach exact target size
  • fit full image inside target size (only applies if reduced)
1: Thumbnail generation mode (like 0 but no image enlargement)
  • don't enlarge image
  • reduce image to fit in target size (if required)
  • keep image aspect ratio / proportions intact
  • fill up with bgcolor to reach exact target size
  • fit full image inside target size (only applies if reduced)
2: Scale to exact target size, crop what does not fit
  • enlarge image to fit in target size (if required)
  • reduce image to fit in target size (if required)
  • keep image aspect ratio / proportions intact
  • fit full image inside target size (crop what does not fit)
3: Scale and keep image proportions, target size variable
  • enlarge image to fit in target size (if required)
  • reduce image to fit in target size (if required)
  • keep image aspect ratio / proportions intact
  • scaled image will not be padded or cropped, so target size is likely not the exact requested size
4: Don't keep image proportions, use exact target size
  • enlarge image to fit in target size (if required)
  • reduce image to fit in target size (if required)
  • don't keep image aspect ratio / proportions intact
  • the image will be scaled exactly to the given target size and likely will be loose proportions
5: Scale and keep image proportions without enlargement, target size variable with optional max width and height
  • dont't enlarge image
  • reduce image to fit in target size (if required)
  • keep image aspect ratio / proportions intact
  • best fit into target width / height _OR_ width / maxHeight _OR_ maxWidth / height
  • scaled image will not be padded or cropped, so target size is likely not the exact requested size
scalePositionfalsetruejava.lang.StringSpecify how the original image is placed if cropped or padded. The following values are supported:
0 (default)
center
1
lower left
2
lower right
3
lower middle
4
center left
5
center right
6
upper middle
7
upper left
8
upper right
scaleFilterfalsetruejava.lang.StringSpecify filters applied to the image (and also to a possibly present padding).
The following values can be given as colon (":") separated list:
shadow
Adds a shadow effect to the image.
grayscale
Renders the image in grayscale.
scaleQualityfalsetruejava.lang.StringAn non-negative integer specifying the scale quality in percent.
Allowed are values between 0 and 100, where 0 is a special value to use the default quality. The value has only influence on image formats that support a quality setting, e.g. JPEG.

Default: 0.
scaleColorfalsetruejava.lang.StringThe color used as backgroud if padding is neccessary. The following values are supported:
transparent (default)
Transparent background, if supported by the image type, e.g. for PNG. If transparent background is not supported, e.g. by JPEG, the value defaults to white (FFFFFF).
000000 - FFFFFF
Hexadecimal RGB color code.
scaleRendermodefalsetruejava.lang.StringSet the image processing mode.
The following values are supported:
0 (default)
Quality. Best possible image processing. Might be slow.
1
Medium. Use default JVM settings. Almost as slow as quality mode. Not recommended.
2
Speed. Fast image processing. But quality might be not as good as in quality mode.
The setting is recommended for thumbnail generation.
hiDpiVariantsfalsetruejava.lang.StringOptional comma separated list of hi DPI veariants to produce, e.g. "1.3x,1.5x,2x,3x". If you only need the "retina" variant, use "2x". Hi DPI variants may be found in the resulting image bean in the map "hiDpiImages".
varfalsetruejava.lang.StringThe name of the variable used to store the resulting image bean

Variables
NameTypeDeclareScopeDescription
From attribute 'var'org.opencms.jsp.util.CmsJspImageBeantrueAT_BEGINBean containing the scaled image.


Output Generated by Tag Library Documentation Generator. Java, JSP, and JavaServer Pages are trademarks or registered trademarks of Sun Microsystems, Inc. in the US and other countries. Copyright 2002-4 Sun Microsystems, Inc. 4150 Network Circle Santa Clara, CA 95054, U.S.A. All Rights Reserved.