Class OutputProfiler.SimpleImageAction
- java.lang.Object
-
- org.faceless.pdf2.OutputProfiler.SimpleImageAction
-
- All Implemented Interfaces:
OutputProfiler.ImageAction
- Enclosing class:
- OutputProfiler
public static class OutputProfiler.SimpleImageAction extends java.lang.Object implements OutputProfiler.ImageAction
An implementation ofOutputProfiler.ImageAction
that implements the functionality that was available via theOutputProfiler.setMaxImageDPI(org.faceless.pdf2.OutputProfiler.ImageType, float, float)
method.- Since:
- 2.22.2
-
-
Constructor Summary
Constructors Constructor Description SimpleImageAction()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description float
resample(OutputProfiler profiler, PDFImage image, java.util.Map<java.lang.String,java.lang.Object> properties)
Optionally causes an image embedded in the PDF to be resampled or recompressed.void
setRule(OutputProfiler.ImageType type, float threshold, float target)
Set a resampling rule.
-
-
-
Method Detail
-
setRule
public void setRule(OutputProfiler.ImageType type, float threshold, float target)
Set a resampling rule. Any images of the specified type that have a minimum DPI of above the "threshold" value will be resampled to "target". For example,setRule(ImageType.Color, 450, 300)
will resample any images above 450dpi down to 300dpi, and leave any images under 450dpi unchanged.This method is called by
OutputProfiler.setMaxImageDPI(org.faceless.pdf2.OutputProfiler.ImageType, float, float)
- Parameters:
type
- the image typethreshold
- the threshold resolutiontarget
- the target resolution- Since:
- 2.28.3
-
resample
public float resample(OutputProfiler profiler, PDFImage image, java.util.Map<java.lang.String,java.lang.Object> properties)
Description copied from interface:OutputProfiler.ImageAction
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:
compression The compression algorithm; normally one of flate, lzw, dct, ccitfax, jbig2 or jpx occurrance The number of times this image occurs in the PDF minResolution The lowest resolution the image appears at. This is normally the one used to make resampling decisions maxResolution The highest resolution the image appears at. compressionRatio The compression ratio of the image inline Optional, 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.
- Specified by:
resample
in interfaceOutputProfiler.ImageAction
- Parameters:
profiler
- the OutputProfiler this action is being run onimage
- the image being consideredproperties
- 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.
-
-