Nutty Peanut Marshmallow

    is-animated-gif
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.3 • Public • Published

    Contributors Forks Stargazers Issues CircleCI ISC License

    is-animated-gif

    Detect animated GIFs from JavaScript buffers. Also supported with Typescript.

    Motivation

    Process the streamed/buffered GIF files to determine whether it is an animated GIF or not. This is a rewritten code based off on another work as a purpose to adapt to TypeScript: https://github.com/mailcharts/animated-gif-detector

    Installation

    NPM:

    npm i is-animated-gif

    Yarn:

    yarn add is-animated-gif

    Usage/Functions

    Async (Stream)

    This function is intended to be used with Stream:

    Function: isAnimatedGifStream()

    Params: Stream (such as: stream.Stream, stream.Readable, or http.IncomingMessage)

    Returns: Boolean

    Example:

    const file = path.resolve(`./test/files/large-size-not-animated.gif`);
    const stream = fs.createReadStream(file);
    isAnimatedGifStream(stream);
    // ...

    External Image example:

    http.get(
      'http://smb3a.weebly.com/uploads/1/0/0/7/1007956/7027030.gif',
      async (res) => {
        const result = await isAnimatedGifStream(res);
        // ...
      }
    );

    Sync (Buffer)

    This function is intended to be used with Buffer:

    Function: isAnimatedGif()

    Params: Buffer

    Returns: Boolean

    Example:

    const file = path.resolve('./path/to/file.gif');
    const buffer = fs.readFileSync(file);
    isAnimatedGif(buffer);
    // ...

    Tests

    Simply execute npm test or yarn test runs the tests.

    Please contribute weird animated GIFs to the repository to add to the test cases.

    Credits

    Special thanks to the MailChart team and other contributers for their hard work!

    Install

    npm i is-animated-gif

    DownloadsWeekly Downloads

    5

    Version

    1.0.3

    License

    ISC

    Unpacked Size

    28 kB

    Total Files

    9

    Last publish

    Collaborators

    • hypernovatx