0.4.0 • Published 2 years ago

read-pixels v0.4.0

Weekly downloads
14
License
CC0-1.0
Repository
github
Last release
2 years ago

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[....] }
0.3.0

2 years ago

0.4.0

2 years ago

0.2.2

3 years ago

0.2.1

3 years ago

0.1.0

3 years ago

0.2.0

3 years ago

0.0.1

3 years ago