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

    InterfaceJPEGEncodeOptions

    Options of Image.encodeJPEG

    interface JPEGEncodeOptions {
        background?: number;
        gainMap?: boolean | GainMapEmbedOptions;
        metadata?: Metadata;
        progressive?: boolean;
        quality?: number;
        quantization?: "flat" | "standard";
        subsampling?: "4:4:4" | "4:2:0";
    }

    Hierarchy (View Summary)

    Index
    background?: number

    The background color to combine with transparent pixels, since JPEG doesn't support transparency. Opaque images are encoded as they are

    0x000000ff (black)

    gainMap?: boolean | GainMapEmbedOptions

    Whether to write the image's Image.gainMap (an Ultra HDR JPEG, brighter on HDR displays), or how.

    true (written if there is one)

    metadata?: Metadata

    Metadata to include, see Metadata

    progressive?: boolean

    Whether to write a progressive JPEG: the picture first appears blurry as a whole and sharpens while it loads, and the file is about 3% smaller for photos. The pixels are the same, and encoding takes 1.1 to 1.3 times as long. An embedded gain map stays a baseline JPEG

    false

    quality?: number

    The JPEG quality (0-100, 0 is the same as 1)

    90

    quantization?: "flat" | "standard"

    The quantization tables, which decide how coarsely each frequency is stored (not the colors, as in Image.quantize): 'standard' (the JPEG standard's) stores fine detail more coarsely than smooth areas, which softens sharp edges and text first; 'flat' uses the same step for every frequency, which keeps edges and text clearer with fewer visible artifacts. At the same PSNR, files with 'flat' were 3 to 30% smaller in a test of photos and a screenshot; at the same SSIM they ranged from 21% smaller to 15% larger (a photo at a low quality). The same quality makes a larger file with 'flat': lower it until the size matches (by about 15 to 25 around quality 60 for photos). Qualities 96 to 100 give the same 'flat' file. Not used for the gain map

    'standard'

    subsampling?: "4:4:4" | "4:2:0"

    How much color detail to keep: '4:4:4' keeps it all; '4:2:0' stores less color detail to make a smaller file (often hard to notice in photos, but more visible around colored edges)

    '4:2:0' up to quality 90, '4:4:4' above