Manipulate Images in Node.js
npm i node-js-image
const Image = require("node-js-image")
// read image from a file
const img = new Image().fromFile('my-image-file.jpg')
// or as a shortcut
const img = new Image({fname: 'my-image-file.jpg'})
Currently available methods:
- blackwhite
- grayscale
- invert
- mask
- reduce
- rotate
Clockwise rotation by 90°
// 90° clock-wise
img.rotate()
// chain the rotate() method
// 270 °clock-wise
img.rotate().rotate().rotate()
Invert the colors
img.invert()
Reduce the colors to Black and White only
img.blackwhite()
// filepath, quality (0-100)
img.toFile('output.jpg', 100)
You can chain the methods
img.invert()
.blackwhite()
.rotate()
.toFile('output.jpg')