Interface DecodeOptions

Options of Image.decode

interface DecodeOptions {
    applyColorProfile?: boolean;
    applyOrientation?: boolean;
    maxPixels?: number;
    threads?: number;
    toneMapping?: ToneMapping;
}

Properties

applyColorProfile?: boolean

Whether to convert the colors of images with an embedded ICC profile (PNG, JPEG, WebP, AVIF, JPEG XL, TIFF), and of AVIFs with other color primaries than sRGB's (Display P3, BT.2020), to sRGB, like browsers show them: wide gamut photos (Display P3 from phones, Adobe RGB, ProPhoto) look as intended instead of washed out. Matrix/TRC profiles (RGB and gray) are applied, relative colorimetric (colors outside sRGB are clipped); profiles with only lookup tables, CMYK ones and ones that are sRGB anyway leave the pixels as they are. Default: true

applyOrientation?: boolean

Whether to rotate/mirror JPEGs, TIFFs, PNGs and WebPs as their orientation tag (Exif or XMP) says. Default: true

maxPixels?: number

The most pixels to decode: larger images throw a RangeError before anything that size is allocated, so small files declaring huge images (decompression bombs) can't exhaust the memory. Default: 268402689 (16383², like sharp), Infinity for no limit

threads?: number

At most this many worker threads decode in parallel (lossy JPEG XLs from 4 megapixels on, one per 2 megapixels at most, lossless ones from 1.5 megapixels and 512 KiB on; AVIFs from 4 megapixels on: the conversion to RGB, one per megapixel, and the tiles of grids), 1 for none. Default: the processors available, at most 8 (1 where workers can't share memory)

toneMapping?: ToneMapping

How Radiance HDRs, PFMs and HDR (PQ or HLG) AVIFs and JPEG XLs, whose light can be brighter than (SDR) white, become 8 bit sRGB: 'reinhard' compresses the brightest parts like Reinhard's tone mapping operator does (the brightest pixel becomes white, images no brighter than white stay as they are), 'clamp' clamps everything brighter than white. Default: 'reinhard'