Class CropScaleImageThumbnailGenerator

  • All Implemented Interfaces:
    IImageThumbnailGenerator, Serializable

    public final class CropScaleImageThumbnailGenerator
    extends Object
    implements IImageThumbnailGenerator
    A thumbnail generator that scales down images to a defined width and height. Scales (down) images so to the configured size. The aspect ratio is preserved. Images with an aspect ratio that does not match the requested width and height are cropped appropriately, so that the generated thumbnails always have the exact configured width and height.
    Since:
    8.3.0
    Author:
    XIMA MEDIA GmbH
    See Also:
    Serialized Form
    • Method Detail

      • generateThumbnail

        public TypedFile generateThumbnail​(Path sourceImage,
                                           Path outputLocation,
                                           ImageThumbnailGeneratorConstraints constraints)
                                    throws IOException
        Description copied from interface: IImageThumbnailGenerator
        Generate a thumbnail for the given image file, and stores it at the specified output location. The output location may be either an existing directory, in which case a new file is created within that directory, or a file path. If the file exists, it is overwritten.
        Specified by:
        generateThumbnail in interface IImageThumbnailGenerator
        Parameters:
        sourceImage - The image file for which to generate a thumbnail.
        outputLocation - Where to store the thumbnail. Either an existing folder or a file path.
        constraints - Requested constraints on the thumbnail generation. May or may not be respected by the implementation. null if no constraints are specified.
        Returns:
        The generated thumbnail file.
        Throws:
        IOException - If the thumbnail could not be generated.
      • generateThumbnail

        public TypedFile generateThumbnail​(String fileName,
                                           InputStream sourceImage,
                                           Path outputLocation,
                                           ImageThumbnailGeneratorConstraints constraints)
                                    throws IOException
        Description copied from interface: IImageThumbnailGenerator
        Generate a thumbnail for the given image file, and stores it at the specified output location. The output location may be either an existing directory, in which case a new file is created within that directory, or a file path. If the file exists, it is overwritten.
        Specified by:
        generateThumbnail in interface IImageThumbnailGenerator
        Parameters:
        fileName - The name of the image file for which to generate a thumbnail.
        sourceImage - The data of the image file for which to generate a thumbnail.
        outputLocation - Where to store the thumbnail. Either an existing folder or a file path.
        constraints - Requested constraints on the thumbnail generation. May or may not be respected by the implementation. null if no constraints are specified.
        Returns:
        The generated thumbnail file.
        Throws:
        IOException - If the thumbnail could not be generated.
      • builder

        public static CropScaleImageThumbnailGenerator.Builder builder()
        Gets a builder for a thumbnail generator that scales down images to a defined width and height. Images that do not fit the aspect ratio are cropped appropriately.
        Returns:
        A builder for a thumbnail generator.