Neanderthals Programming Machines
    Share your code. npm Orgs help your team discover, share, and reuse code. Create a free org »

    get-image-datapublic

    get-image-data

    get-image-data is a browser/server utility that extracts RGBA data from images. It also provides the image’s height and width.

    Build status

    Browser support

    Install

    $ npm install get-image-data

    note: canvas is not installed alongside get-image-data

    get-image-data requires automattic/node-canvas for its server/node variant, however, to avoid browser-only users from having to endure the native compilation process, it needs to be npm installed separately.

    Usage

    Browser & Server

    var image = require('get-image-data')
     
    image('./image.jpg', function(error, info) {
      var height = info.height
      var width = info.width
      var data = info.data
     
      for (var i = 0, l = data.length; i < l; i += 4) {
        var red = data[i]
        var green = data[+ 1]
        var blue = data[+ 2]
        var alpha = data[+ 3]
      }
    })

    Note

    The image data will be contained within either a Uint8ClampedArray or a CanvasPixelArray depending on the environment. This shouldn’t be a problem, but it’s worth knowing.

    License

    MIT

    install

    npm i get-image-data

    Downloadsweekly downloads

    114

    version

    3.0.1

    license

    MIT

    homepage

    github.com

    last publish

    collaborators

    • avatar