JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 119
  • Score
    100M100P100Q89384F
  • License CC0-1.0

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.

Package Exports

  • read-pixels
  • read-pixels/dist/read-pixels.min.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (read-pixels) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

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?

0️⃣ Zero Dependencies

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