Socket
Socket
Sign inDemoInstall

read-pixels

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    read-pixels

Super Lightweight Function to Read Pixels in the Browser. Reads Pixels from JPG, PNG, and WebP Files in Multiple Formats, including ArrayBuffer, Data URL, Files, Response, and Typed Array.


Version published
Weekly downloads
156
increased by47.17%
Maintainers
1
Install size
14.3 kB
Created
Weekly downloads
 

Readme

Source

read-pixels

Super Lightweight Function to Read Pixels in the Browser

Reads Pixels from JPG, PNG, and WebP Files in Multiple Formats, including ArrayBuffer, Data URL, Files, Response, and Typed Array.

why?

:zero: Zero Dependencies

:rocket: Super Lightweight at 1.24 KB File Size

install

npm install read-pixels

usage

import readPixels from 'read-pixels';

// reading array buffer
const result = await readPixels({
  data: await fetch("./flower.png").then(r => r.arrayBuffer()),
  debug: true // set debug to true for more logging
});
// result is { height: 100, width: 100, pixels: ClampedUint8Array[....] }

// reading Response
const result = await readPixels({
  data: fetch("./flower.png"),
  debug: true // set debug to true for more logging
});
// result is { height: 100, width: 100, pixels: ClampedUint8Array[....] }

// reading data url
const result = await readPixels({
  data: "data:image/png;base64,...",
  debug: true // set debug to true for more logging
});
// result is { height: 100, width: 100, pixels: ClampedUint8Array[....] }

Keywords

FAQs

Last updated on 13 Feb 2022

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc