All Projects → saschanaz → libflif.js

saschanaz / libflif.js

Licence: ISC License
Another trial to get FLIF to the web platform

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to libflif.js

node-flif
A Node wrapper for the FLIF executable
Stars: ✭ 43 (+7.5%)
Mutual labels:  flif
flif.rs
flif decoder written in Rust
Stars: ✭ 60 (+50%)
Mutual labels:  flif
Flif
Free Lossless Image Format
Stars: ✭ 3,668 (+9070%)
Mutual labels:  flif
Phew
FLIF image viewer and QuickLook plugin for macOS
Stars: ✭ 74 (+85%)
Mutual labels:  flif

libflif.js

Another trial to get FLIF to the web platform. Sample page here.

Use

  1. Get lib/wrapper.js, lib/worker.js, lib/libflif.js, lib/libflif.js.mem in the same directory
  2. (Optionally) define libflifjs global variable of which the format is:
    {
        "libDir": "String. the directory of worker.js and libflif.js. Insert this if the HTML file and libflifjs files are in different directories.",
        "debug": "Boolean. If this is true then worker will emit debug console message."
    }
  3. Insert lib/wrapper.js script tag on your HTML file

API

declare namespace libflif {
    // call this to prepare worker before any decoding/encoding calls
    function startWorker(): void;

    function decode(input: ArrayBuffer | Blob, callback: (result: libflifProgressiveDecodingResult) => any, options?: libflifDecoderOptions): Promise<void>;
    function encode(input: libflifEncoderInput): Promise<ArrayBuffer>;
}

interface libflifDecoderInput {
    data: ArrayBuffer;

    options?: libflifDecoderOptions;
}

interface libflifDecoderOptions {
    crcCheck?: boolean;
    quality?: number;
    scale?: number;
    resize?: [number, number];
    fit?: [number, number];
    
    // progressive callback
    progressiveInitialLimit?: number;
    progressiveStep?: number;
}

interface libflifProgressiveDecodingResult {
    quality: number;
    bytesRead: number;
    frames: libflifFrame[];
    loop: number;
}

interface libflifFrame {
    data: ArrayBuffer;
    width: number;
    height: number;
    depth?: number;
    frameDelay?: number;
}

interface libflifEncoderOptions {
    interlaced?: boolean;
    learnRepeat?: number;
    autoColorBuckets?: boolean;
    paletteSize?: number;
    lookback?: number;
    divisor?: number;
    minSize?: number;
    splitThreshold?: number;
    alphaZeroLossless?: boolean;
    chanceCutoff?: number;
    chanceAlpha?: number;
    crcCheck?: boolean;
    yCoCg?: boolean;
    frameShape?: boolean;
}

interface libflifEncoderInput {
    frames: libflifFrame[];
    loop?: number;

    options?: libflifEncoderOptions;
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].