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

    InterfaceAPNGEncodeOptions

    Options of Animation.encodeAPNG and Animation.apngEncoder: those of PNGEncodeOptions, and the animation options

    interface APNGEncodeOptions {
        colors?: number;
        compression?: number;
        dither?: DitherMethod;
        ditherStrength?: number;
        metadata?: Metadata;
        optimize?: boolean;
        threads?: number;
    }

    Hierarchy (View Summary)

    Index
    colors?: number

    Lossy: the maximum colors in the palette (2-256, including transparency), each with its own transparency, so soft edges and shadows stay soft. Makes photos with transparency and graphics with gradients much smaller. Images with no more colors keep them exactly (the file is the same as without this option); otherwise ImageScript chooses representative colors and applies dither. Fully transparent pixels lose their hidden color. The image itself stays unchanged

    None: the PNG is lossless
    

    Flat or smoothly shaded graphics without noise can be smaller as lossless PNGs, and dithering makes them larger: try dither: 'none', and compare

    compression?: number

    The compression level (0-9), higher is smaller but slower

    4

    dither?: DitherMethod

    How to spread small color changes across nearby pixels to make gradients look smoother with few colors, see DitherMethod

    'floyd-steinberg'

    ditherStrength?: number

    How strongly to apply dithering: 0 disables it (like 'none'); 1 applies it fully

    0.85

    metadata?: Metadata

    Metadata to include, see Metadata

    optimize?: boolean

    Whether to store each frame as the area that changed since the frame before and merge identical frames, which usually makes files a lot smaller. The file shows the same animation either way, but only decodes to the same frames without it, which also encodes faster when little changes. The exception is GIF, which has no partial transparency: without optimize, a semi-transparent pixel becomes opaque or transparent in its own frame, with it the frames are composited first

    true

    threads?: number

    Maximum threads for compression. Small images (under 2 MiB of pixel data) and runtimes without node:zlib (such as browsers) use one thread

    The image is compressed in pieces of 1 MiB on node:zlib's thread pool, not in workers, so the file is the same for any number of threads. Node's pool has 4 threads unless UV_THREADPOOL_SIZE says otherwise

    The available processors, up to 8