Socket
Socket
Sign inDemoInstall

node-js-image

Package Overview
Dependencies
1
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    node-js-image

Manipulate Images in Node.js


Version published
Weekly downloads
14
increased by1300%
Maintainers
1
Install size
86.5 kB
Created
Weekly downloads
 

Readme

Source

Image

Manipulate Images in Node.js

Installation

npm i node-js-image

How to Use

Read the Image Data

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'})

Process the Image Data

Currently available methods:

  • blackwhite
  • grayscale
  • invert
  • mask
  • reduce
  • rotate

Examples

rotate

Clockwise rotation by 90°

// 90° clock-wise
img.rotate()

// chain the rotate() method
// 270 °clock-wise
img.rotate().rotate().rotate()
invert

Invert the colors

img.invert()
blackwhite

Reduce the colors to Black and White only

img.blackwhite()

Save the Image to File

// filepath, quality (0-100)
img.toFile('output.jpg', 100)

Method Chaining

You can chain the methods

img.invert()
  .blackwhite()
  .rotate()
  .toFile('output.jpg')

Keywords

FAQs

Last updated on 25 Feb 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc