modern-pdf-lib / ImageOptimizeOptions
Interface: ImageOptimizeOptions
Defined in: src/assets/image/imageOptimize.ts:114
Combined options for the full optimization pipeline.
Extends
Properties
algorithm?
readonlyoptionalalgorithm:"nearest"|"bilinear"|"lanczos"
Defined in: src/assets/image/imageOptimize.ts:56
Resampling algorithm.
'nearest': Nearest-neighbor (fast, blocky)'bilinear': Bilinear interpolation (good quality, moderate speed)'lanczos': Lanczos-3 resampling (best quality, slowest)
Default: 'bilinear'.
Inherited from
chromaSubsampling?
readonlyoptionalchromaSubsampling:ChromaSubsampling
Defined in: src/assets/image/imageOptimize.ts:108
Chroma subsampling mode. Only used when format is 'jpeg'.
'4:4:4': No subsampling — best color fidelity, largest file.'4:2:2': Horizontal subsampling — good balance.'4:2:0': Both horizontal and vertical — smallest file.
Requires the JPEG WASM module to be initialized.
Default: '4:2:0'.
Inherited from
RecompressOptions.chromaSubsampling
compressionLevel?
readonlyoptionalcompressionLevel:1|6|3|2|4|5|7|8|9
Defined in: src/assets/image/imageOptimize.ts:84
Deflate compression level (1–9). Only used when format is 'deflate'. Higher values produce smaller files but take longer.
Default: 6.
Inherited from
RecompressOptions.compressionLevel
format?
readonlyoptionalformat:"jpeg"|"deflate"
Defined in: src/assets/image/imageOptimize.ts:70
Output format.
'jpeg': JPEG compression (lossy, good for photographs)'deflate': Deflate/zlib compression (lossless, used in PDF FlateDecode)
Default: 'deflate'.
Inherited from
maxHeight?
readonlyoptionalmaxHeight:number
Defined in: src/assets/image/imageOptimize.ts:28
Target maximum height in pixels. The image is scaled proportionally.
Inherited from
maxWidth?
readonlyoptionalmaxWidth:number
Defined in: src/assets/image/imageOptimize.ts:26
Target maximum width in pixels. The image is scaled proportionally.
Inherited from
printHeight?
readonlyoptionalprintHeight:number
Defined in: src/assets/image/imageOptimize.ts:47
Intended print height in points (1/72 inch). Used together with targetDpi to compute the target pixel dimensions.
Inherited from
printWidth?
readonlyoptionalprintWidth:number
Defined in: src/assets/image/imageOptimize.ts:42
Intended print width in points (1/72 inch). Used together with targetDpi to compute the target pixel dimensions.
Inherited from
progressive?
readonlyoptionalprogressive:boolean
Defined in: src/assets/image/imageOptimize.ts:96
Encode as progressive JPEG. Only used when format is 'jpeg'.
Progressive JPEGs render in multiple passes (low-res → full-res) which improves perceived loading speed on slow connections. They are also often slightly smaller than baseline JPEGs.
Requires the JPEG WASM module to be initialized.
Default: false.
Inherited from
quality?
readonlyoptionalquality:number
Defined in: src/assets/image/imageOptimize.ts:77
JPEG quality (1–100). Only used when format is 'jpeg'. Higher values produce larger files with better quality.
Default: 85.
Inherited from
skipBelowBytes?
readonlyoptionalskipBelowBytes:number
Defined in: src/assets/image/imageOptimize.ts:121
Skip optimization if the input data is already smaller than this threshold (in bytes).
Default: 0 (always optimize).
targetDpi?
readonlyoptionaltargetDpi:number
Defined in: src/assets/image/imageOptimize.ts:37
Target DPI for the image at its intended print size. If specified along with printWidth / printHeight, the image is downscaled to match the target DPI.
For example, a 3000×2000 image printed at 10×6.67 inches would be 300 DPI. Setting targetDpi: 150 would downscale to 1500×1000.