GithubHelp home page GithubHelp logo

doc22940 / animated-gif-detector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chadboyda/animated-gif-detector

1.0 1.0 0.0 9.13 MB

Detect animated GIF from JavaScript buffers.

JavaScript 100.00%

animated-gif-detector's Introduction

animated-gif-detector

Detect animated GIFs from JavaScript buffers.

Installation

npm i animated-gif-detector

Motivation

Given a readable stream or a buffer directly, determine if a buffer of data is an animated GIF. This helps determine if a document contains cat pics or LOLz.

Usage

Streaming

This module is intended to be used as a Writable stream:

var fs = require('fs')
  , animated = require('animated-gif-detector')
;
fs.createReadStream('file.gif')
  .pipe(animated())
  .on('animated', function() {
    console.log('detected animation!');
  }); 
;

Particularly, you may want to determine animate as early as possible in a given HTTP request, and abort the request as soon as you know:

var http = require('http')
  , animated = require('animated-gif-detector')
;
var req = http.get('http://domain.com/file.gif')
  .pipe(animated())
  .once('animated', function() {
    req.abort();
    // do something else!
  })
;

Sync

If an img is loaded as a buffer directly, a sync function is also available:

var fs = require('fs')
  , animated = require('animated-gif-detector')
;

animated(fs.readFileSync('file.gif')) // => true!

Browserify

This should work as a client-side package if Browersified.

Tests

npm test runs the tests.

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

Contributors

Thanks to hard work from the following contributors:

animated-gif-detector's People

Contributors

automata avatar bspaulding avatar papandreou avatar tbuchok avatar

Stargazers

 avatar

Watchers

 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.