Class ImageUploadProcessor
- java.lang.Object
-
- de.xima.fc.form.common.upload.image.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 Summary
Constructors Constructor Description ImageUploadProcessor(ImageCompression compression, Path tempDir, Consumer<String> protocolEntryHandler)Creates a new postprocessor for uploaded images.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisProcessable(IXUpload upload)IXUploadprocess(IXUpload upload)
-
-
-
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, ornullto only adjust its orientation and remove its metadata.tempDir- Directory to store the processed image in until it has been read, ornullto 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:
isProcessablein interfaceIUploadPostProcessor- Parameters:
upload- the source upload- Returns:
- true if the provided upload can be processed by this processor, false if not.
-
process
public IXUpload process(IXUpload upload)
- Specified by:
processin interfaceIUploadPostProcessor- Parameters:
upload- the upload to be procesed- Returns:
- the resulting data
-
-