A JavaScript library for applying a series of transformations to images.
- Convert an image to grayscale
- Invert an image in the x or y direction
Example of converting an image to grayscale:
let ImgProc = new ImageProcessor()
ImgProc.init("image.png").then(() => {
//convert image to grayscale
ImgProc.grayscale()
})Example of inverting an image in the x direction:
let ImgProc = new ImageProcessor()
ImgProc.init("image.png").then(() => {
//invert image
ImgProc.invert('x-axis')
})Follow these steps to use this library in your own project.
- Clone the repo.
$ git clone https://github.com/Rclodeca/Image-Processing-Library
$ cd Image-Processing-Library
- Install dependencies
$ npm install- Require to use the project
const ImageProcessor = require('Path_to_index.js_here');Additionally to test it:
$ npm testIdeally this would actually be an npm install ImageProcessor
Create an ImageProcessor object.
let IP = new ImageProcessor();file is a string with the path to the image file.
Initialize the file that is to be transformed. Supported file types are .jpg and .png. Init() is asynchronous so you must use a callback function to preform the transformations.
let IP = new ImageProcessor()
IP.init("image.png").then(() => {
//do something
})Methods of ImageProcessor to transform images.
Transforms the image to grayscale.
let IP = new ImageProcessor()
IP.init("image.png").then(() => {
IP.grayscale()
})type is a string containing either 'x-axis' for left-right inverting or 'y-axis' for up-down inverting. If type is left out, the default is 'x-axis'.
Inverts the image in either the x or y direction.
Example of x direction:
let IP = new ImageProcessor()
IP.init("image.png").then(() => {
IP.invert('x-axis')
})Example of y direction:
let IP = new ImageProcessor()
IP.init("image.png").then(() => {
IP.invert('y-axis')
})Tests all methods of ImageProcessor.
npm test
MIT © Rclodeca