@fast-pixel/clip

0.0.1 • Public • Published

@fast-pixel/clip

Clip Pixels

install

npm install @fast-pixel/clip

usage

clipping png file

If we wanted to remove two pixels from the edge of the image.

const fs = require("fs");
const readPNG = require("read-png");
const clip = require("@fast-pixel/clip");

const png = await readPNG({ data: fs.readFileSync("./flower.png") });

const clipping = clip({
  data: png.pixels, // numerical array of pixel values

  /*
    dimensions of the output / clipping 
    1: all the pixels are interleaved like r0,g0,b0,a0,r1,g1,b1,a1,...
    2: an array of band values where [ [r0, r1, r2, ...], [g0, g1, g2, ...] ]
    3: by band then row the column [ [ b0r0c0, b0r0c1 ] ... ]
  */
  ndim: 3, 

  top: 2, // how far from the top to start clipping
  bottom: png.height - 2, // how far from the top to stop clipping

  left: 2, // how far from the left to start clipping
  right: png.width - 2 // how far from the left to start clipping

  height: png.height // height of the input image
  width: png.width // width of the input image
})

Readme

Keywords

Package Sidebar

Install

npm i @fast-pixel/clip

Weekly Downloads

3

Version

0.0.1

License

CC0-1.0

Unpacked Size

4.44 kB

Total Files

3

Last publish

Collaborators

  • danieljdufour