Class JpegCompressor
java.lang.Object
com.itextpdf.pdfoptimizer.handlers.imagequality.processors.JpegCompressor
- All Implemented Interfaces:
-
IImageProcessor
Class is used to compress images as JPEG. If the
PdfImageXObject has /Mask entry as PdfArray then it will be converted into mask as a stream.
-
Constructor Summary
ConstructorsConstructorDescriptionJpegCompressor(double compressionLevel) Creates an instance of JPEG image processor. -
Method Summary
Modifier and TypeMethodDescriptioncom.itextpdf.kernel.pdf.xobject.PdfImageXObjectprocessImage(com.itextpdf.kernel.pdf.xobject.PdfImageXObject objectToProcess, OptimizationSession session) Compresses a JPEG image presented asPdfImageXObjectwith the configured compression level.
-
Constructor Details
-
JpegCompressor
public JpegCompressor(double compressionLevel) Creates an instance of JPEG image processor.- Parameters:
-
compressionLevel- is a compression coefficient. The value should be in range [0.0, 1.0]
-
-
Method Details
-
processImage
public com.itextpdf.kernel.pdf.xobject.PdfImageXObject processImage(com.itextpdf.kernel.pdf.xobject.PdfImageXObject objectToProcess, OptimizationSession session) throws IOException Compresses a JPEG image presented asPdfImageXObjectwith the configured compression level.- Specified by:
-
processImagein interfaceIImageProcessor - Parameters:
-
objectToProcess- is aPdfImageXObjectrepresenting the image -
session- is an auxiliary object used to support share data between stages of optimization process - Returns:
- processed image if processing can be performed and the same instance otherwise
- Throws:
-
IOException- if image cannot be compressed as JPEG image
-