Coder Social home page Coder Social logo

tamzinselvi / libflif.js Goto Github PK

View Code? Open in Web Editor NEW

This project forked from saschanaz/libflif.js

0.0 1.0 0.0 5.25 MB

Another trial to get FLIF to the web platform

License: ISC License

JavaScript 99.59% HTML 0.03% TypeScript 0.22% C++ 0.15%

libflif.js's Introduction

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;
}

libflif.js's People

Contributors

saschanaz avatar

Watchers

Tamzin Selvi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.