modern-pdf-lib / downscaleImage
Function: downscaleImage()
downscaleImage(
image,options?):RawImageData
Defined in: src/assets/image/imageOptimize.ts:198
Downscale an image to fit within the specified dimensions.
If the image is already smaller than the target dimensions, it is returned unchanged.
Parameters
image
The raw image pixel data.
options?
DownscaleOptions = {}
Downscaling options (target dimensions, algorithm).
Returns
The downscaled image, or the original if no scaling needed.
Example
ts
const result = downscaleImage(rawImage, {
maxWidth: 1024,
maxHeight: 768,
algorithm: 'bilinear',
});