Class ImageUploadProcessor

  • All Implemented Interfaces:
    IUploadPostProcessor

    public final class ImageUploadProcessor
    extends Object
    implements IUploadPostProcessor
    Upload postprocessor for images. It always adjusts the orientation an image is stored with and removes its metadata (which may hold anything from a thumbnail of the unprocessed image to the GPS coordinates of the place it was taken at). When compression settings are given, it also scales the image down and converts it to the configured format.

    Both happen in a single step on purpose: an image that is decoded and encoded twice is compressed twice, and every compression of a format such as JPEG costs quality that cannot be recovered.

    Since:
    8.6.0
    Author:
    XIMA MEDIA GmbH
    • Constructor Detail

      • ImageUploadProcessor

        public ImageUploadProcessor​(ImageCompression compression,
                                    Path tempDir,
                                    Consumer<String> protocolEntryHandler)
        Creates a new postprocessor for uploaded images.
        Parameters:
        compression - The compression to apply to the uploaded image, or null to only adjust its orientation and remove its metadata.
        tempDir - Directory to store the processed image in until it has been read, or null to use the temporary directory of the system.
        protocolEntryHandler - Accepts the i18n keys of the messages to add to the form record's history.
        Since:
        8.6.0
    • Method Detail

      • isProcessable

        public boolean isProcessable​(IXUpload upload)
        Specified by:
        isProcessable in interface IUploadPostProcessor
        Parameters:
        upload - the source upload
        Returns:
        true if the provided upload can be processed by this processor, false if not.