Interface OutputProfiler.ImageAction

  • All Known Implementing Classes:
    OutputProfiler.SimpleImageAction
    Enclosing class:
    OutputProfiler

    public static interface OutputProfiler.ImageAction
    An action that can be used to resample or recompress bitmap images.
    Since:
    2.22.2
    • Method Detail

      • resample

        float resample​(OutputProfiler profiler,
                       PDFImage image,
                       Map<String,​Object> properties)

        Optionally causes an image embedded in the PDF to be resampled or recompressed. Returning a value other than 0 from this method will cause the image to be rebuilt; a value of less than 1 will downsample the image but that scaling factor, and the Map of properties may be modified to change the way the image is compressed.

        The supplied map will have at least the following properties:

        compressionThe compression algorithm; normally one of flate, lzw, dct, ccitfax, jbig2 or jpx
        occurranceThe number of times this image occurs in the PDF
        minResolutionThe lowest resolution the image appears at. This is normally the one used to make resampling decisions
        maxResolutionThe highest resolution the image appears at.
        compressionRatioThe compression ratio of the image
        inlineOptional, but if this property exists the image is inline

        The Map may be modified to change the way the image is compressed; specifically the "compression" property may be changed to one of "flate", "dct", "jpx", "ccittfax" ("jbig2" will hopefully be added at some point), and "compressionRatio" may be set - this will be a fairly accurate setting for "jpx", an estimate for "dct", and unused for other types of compression. A valud of "1" for "jpx" will losslessly recompress the image.

        Parameters:
        profiler - the OutputProfiler this action is being run on
        image - the image being considered
        properties - a list of properties which describe how the image is stored. This map can be altered to control how the image is recompressed
        Returns:
        the scaling factor to apply to the image, or 0 for no action.