← 输入框|imagescript.dev|刷新
ImageScript v4.1.0
    Preparing search index...

    InterfaceDecodeOptions

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

    Whether to use the image's embedded color profile (color information describing its pixels) to convert its colors to sRGB, the standard used by most screens and browsers. Common RGB and gray profiles described by a color matrix and tone curves are converted, as are AVIFs using other color ranges (such as Display P3 or BT.2020). Colors outside sRGB are clipped. Profiles that rely on lookup tables, CMYK profiles and profiles already in sRGB are left unchanged

    true

    applyOrientation?: boolean

    Whether to rotate or mirror the image according to its saved orientation information, so photos taken with a rotated camera display upright. This applies to every animation frame too. AVIF's rotation and mirroring (irot, imir) are part of the image in that format and always applied, like other AVIF decoders do

    true

    gainMap?: boolean

    Whether to read extra HDR brightness data (a gain map) from supported JPEG, AVIF and JPEG XL images into Image.gainMap. For animations, this also reads maps from supported JPEG XL frames

    true

    maxPixels?: number

    The maximum total pixels to decode. An image declaring more pixels throws a LimitError (a RangeError) before its pixel buffer is allocated, helping prevent a small or untrusted file from requesting an enormous amount of memory. Animation.decode counts all frames together because each frame uses a full canvas (and at least 1024 pixels, for the memory a frame takes however small it is). The decoded image takes 4 bytes per pixel (about 1 GiB at the default), and decoding needs more while it runs: for 8-bit images, about 4-7 bytes per pixel for PNG, JPEG, WebP, GIF and the simpler formats, about 14 for AVIF and about 60 for lossy JPEG XL on one thread, about 110 with worker threads (more with high bit depths). Lower it to bound the memory of servers decoding untrusted files

    268402689 (16383²); Infinity disables the limit

    threads?: number

    Maximum worker threads for formats and image sizes that can be decoded in parallel. Small images may use one thread because starting workers can take longer than decoding them

    Where workers can't start, the work runs on the calling thread with the same output. That includes browser pages that aren't cross-origin isolated and ones that load the package from another origin (a CDN such as jsDelivr), which browsers don't allow to start workers

    The available processors, up to 8 (one in runtimes that cannot share memory between workers)
    
    toneMapping?: ToneMapping

    How high-dynamic-range images (which can be brighter than a standard screen's white) become 8-bit sRGB. 'reinhard' gently compresses bright highlights so the brightest pixel becomes white; images that are not HDR stay unchanged. 'clamp' clips anything brighter than white

    'reinhard'