Image resizing is an out of the box feature of YC that allows on the fly image resizing to width and height specifications.
The configuration for image sizes are kept in ImageService bean. Image service will determine if there is a resized version of the image and if one does not exist it will resize the image and cache it in the image vault. Because image service can resize any image to any size there is a risk of flooding the HDD with all the different versions of resized images. This is why ImageService is restricted to use only specific dimensions (i.e. width and height) and will return full sized image for invalid parameters.
The configurations for all the different image sizes and resize parameters are configured directly in the Spring bean in core-services.xml
There are several configuration parameters:
Comma separated list of width x height of allowed sizes
|Background RGB||255 255 255||Background RGB color for re-sized picture. When picture is scaled this is the border colour around the picture where it does not fill all the space|
|CropToFit||false||When set to true will crop the image to proper ratio prior to scaling, so that scaled image fills all the space. This is useful for those who wish to have images that fill all space dedicated for image without having border around the image.|
This works best when all images are roughly same diagonal ratio.
For those who wish images of products in the middle e.g. as it is in YC demo better to set this to false.
False works best for non-standard image diagonal ratios (i.e. mix of panoramic, landscape and square images)
|ForceCropToFitOnSize||100||Forcefully uses cropping if width or height is below given size.|
This option is very useful for small thumbs, as you really cannot see much with added padding for panoramic or tall portrait images.
To speed up performance ImageFilter uses ETag in order to abort requests for images that have not been modified. This allows to gain immense performance boost on page loads as image content is not streamed.
ETag timeout is set using System > Preferences > SYSTEM_ETAG_CACHE_IMAGES_TIME which is set in minutes. If the file have not been modified then ImageFilter responds with 304 and Last-Modifed header only.
JPEG resizing in Oracle JDK 7+
In some cases JDK Image IO standard plugins are unable to cope with image files that have certain meta data configurations.