Image Transformations
April 20, 2020 ยท View on GitHub
Apache Sling > Sling CMS > Administration > Image Transformations
Image Transformations
Image transformations are used to transform a file from one format to an image format, most commonly in generating thumbnails or sized down renditions.
Transformation Configurations
File transformations should be created per site configuration at via the Configuration Console:
/conf/[conf-name]/files/transformations

Each transformation is defined as a series of handlers which will be executed in order.
The transformations avaiable in the current site can be retrieved using the TransformationManager which is available as a Sling Model.
Transformation Handlers
Transformation handlers handle each step of transforming an image based on the Thumbnailer library.
Currently, there are two provided Transformation Handlers:
- Crop Handler - Crops images based on "weights"
- Size Handler - Resizes images
To implement a new Transformation Handler, provide a service implementing TransformationHandler, including providing a resource type to configure the transformation handler.
Providing Thumbnails
Thumbnail Providers are used to create renditions of non-image files, for example PDFs or Word documents. There are a number of default providers:
- ImageThumbnailProvider - Returns the image as the thumbnail
- PdfThumbnailProvider - Uses Apache PDFBox to generate a thumbnail of PDF files
- SlideShowThumbnailProvider - Uses Apache POI to generate a thumbnail of PPT and PPTX files
- TikaFallbackProvider - Uses Apache Tika to generate a thumbnail of the text of documents
To implement a new Thumbnail Providers, provide a service implementing ThumbnailProvider.
Transformation Servlet
The Transformation Servlet can be used to retrieve tranformed images for any file. The transformed images can be retrieved by using the extensions transform and the suffix of the transformation name to execute + the output extension. For example:
/content/site/a-file.png.transform/a-thumbnail.png
The transformation servlet is integrated into the reference image component.