java.lang.Object
com.itextpdf.pdfoptimizer.handlers.imagequality.processors.JpegCompressor
All Implemented Interfaces:
IImageProcessor

public class JpegCompressor extends Object implements 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

    Constructors
    Constructor
    Description
    JpegCompressor(double compressionLevel)
    Creates an instance of JPEG image processor.
  • Method Summary

    Modifier and Type
    Method
    Description
    com.itextpdf.kernel.pdf.xobject.PdfImageXObject
    processImage(com.itextpdf.kernel.pdf.xobject.PdfImageXObject objectToProcess, OptimizationSession session)
    Compresses a JPEG image presented as PdfImageXObject with the configured compression level.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 as PdfImageXObject with the configured compression level.
      Specified by:
      processImage in interface IImageProcessor
      Parameters:
      objectToProcess - is a PdfImageXObject representing 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