npm.io
1.0.1 • Published 4 years ago

pixel-shop

Licence
MIT
Version
1.0.1
Deps
0
Size
6 kB
Vulns
0
Weekly
0

Pixel shop

Transform images; given pixel data, width, and height.


Transforms:

  • rotateImageCCW - rotates pixel values to match a counter-clockwise 90º rotation (also returns updated width and height values)
  • invertColors - invert the RGB values of RGBA pixel data (no alpha change)

Usage

For use with ImageData pattern (Uint8ClampedArray, width, height)

Returns { data: (Uint8ClampedArray), width: (number), height: (number) }

For node, read files using image-pixels or get-pixels

import { rotateImageCCW, invertColors } from 'pixel-shop'
import pixels from "image-pixels";

// example image data:
let {data, width, height } = await pixels('example.jpg');

const rotatedExample = rotateImageCCW({ data, width, height });

const invertedColorExample = invertColors({ data, width, height })

appendix

Reference docs
Reading image data in Node
Reading image data in the browser