New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@andreekeberg/imagedata

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@andreekeberg/imagedata

Unified method of retrieving an ImageData instance from an image, in both the browser and Node.js, asynchronously or synchronously

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
65
decreased by-5.8%
Maintainers
1
Weekly downloads
 
Created
Source

ImageData

Version Total Downloads License

Unified method of retrieving an ImageData instance from an image, in both the browser and Node.js, asynchronously or synchronously. Also exports an ImageData polyfill in Node.js, allowing you to type check instances in both environments.

An ImageData object always contains the following properties:

data

Uint8ClampedArray representing a one-dimensional array containing the data in the RGBA order, with integer values between 0 and 255 (inclusive).

width

Unsigned long representing the actual width, in pixels, of the ImageData.

height

Unsigned long representing the actual height, in pixels, of the ImageData.

Supported formats

  • jpeg
  • png
  • gif
  • bmp
  • tiff

Installation

Using npm

npm install @andreekeberg/imagedata

Using yarn

yarn add @andreekeberg/imagedata

Getting started

Import as an ES6 module

import { get, getSync } from '@andreekeberg/imagedata'

Import as a CommonJS module

const { get, getSync } = require('@andreekeberg/imagedata')

Usage (Browser)

Asynchronously

Available input types
TypeDescription
stringPath to image file
HTMLImageElementReference to an <img> element
FileGenerally returned from an <input> element
BlobRaw binary data blob
Example
get('image.jpg', (error, data) => {
    if (error) {
        console.log(error)
    } else {
        console.log(data)
    }
})

Synchronously

Available input types
TypeDescription
HTMLImageElementReference to an <img> element

Throws an Error if the provided image has not completed loading

Example
const image = document.querySelector('img')

try {
    console.log(getSync(image))
} catch(error) {
    console.log(error)
}

Usage (Node.js)

Asynchronously

Available input types
TypeDescription
stringPath to image file
BufferCreated from fs.readFile or fs.readFileSync
fs.ReadStreamCreated from fs.createReadStream
Example
get('image.jpg', (error, data) => {
    if (error) {
        console.log(error)
    } else {
        console.log(data)
    }
})

Synchronously

Available input types
TypeDescription
stringPath to image file
BufferCreated from fs.readFile or fs.readFileSync
Example
try {
    console.log(getSync('image.jpg'))
} catch(error) {
    console.log(error)
}

Documentation

Contributing

Read the contribution guidelines.

Changelog

Refer to the changelog for a full history of the project.

License

ImageData is licensed under the MIT license.

Keywords

FAQs

Package last updated on 18 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc