tinyimg - v1.1.1
    Preparing search index...

    Interface EncodeOptions

    What Image.bytes and its siblings take.

    interface EncodeOptions {
        compression?: "best" | "auto" | "none" | "fast" | "default";
        effort?: "fancy" | "fast";
        lossless?: boolean;
        progressive?: boolean;
        quality?: number;
        stripMetadata?: boolean;
    }
    Index
    compression?: "best" | "auto" | "none" | "fast" | "default"

    How hard a lossless stream should be compressed. 'auto' is the default.

    A third axis, separate from quality and effort, because for PNG and deflate-compressed TIFF the whole output is the compressor's: there is no quantizer to turn down, so quality says nothing and effort only decides how many candidate streams get compressed. 'auto' reads quality, which is what every caller got before this option existed.

    At the longest chain walk this measured 664 bytes against 835 on a logo, for 4.30x the CPU; 'none' entropy codes without searching for matches at all and can beat 'fast' on a photograph's filtered rows.

    Formats with no deflate stream ignore it.

    effort?: "fancy" | "fast"

    How much computation the encoder may spend. 'fancy' is the default.

    A separate axis from EncodeOptions.quality. Quality says what the output should look like; this says how hard to work to get there. 'fast' bounds the WebP encoder's 4x4 prediction search to its four whole-block modes, which over six fixtures at 800 wide measured 1.18x to 1.45x faster for between 8.8% smaller and 17.5% larger, never more than 0.05 dB apart. Flat-color illustrations pay the most, because hard diagonal edges are what the omitted modes are for.

    PNG reads it too, and its trade splits by content. The encoder compresses an adaptively filtered stream and an unfiltered one and keeps the smaller; 'fast' compresses only the adaptive one, which is 1.59x to 2.08x. On a photograph the adaptive stream wins anyway, so the output is byte-identical and the speed costs nothing. On flat artwork the unfiltered stream is the one that would have won, so it pays 7.0% more bytes on a mono GIF, 17.2% on webassembly.png and 63.1% on a 96x96 logo.

    Formats with nothing to trade ignore it and do the exact thing, which includes AVIF: the AV1 encoder has no bounded search to give up.

    lossless?: boolean

    Use the format's lossless mode where it has one.

    progressive?: boolean

    Write a progressive or interlaced stream.

    quality?: number

    Quality for a lossy format, 1 through 100.

    stripMetadata?: boolean

    Drop EXIF and other metadata from the output.