Skip to content

Rclodeca/Image-Processing-Library

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image-Processing-Library

A JavaScript library for applying a series of transformations to images.

Features

  • Convert an image to grayscale
  • Invert an image in the x or y direction

Code Examples

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

})

Installation

Follow these steps to use this library in your own project.

  1. Clone the repo.
$ git clone https://github.com/Rclodeca/Image-Processing-Library
$ cd Image-Processing-Library
  1. Install dependencies
$ npm install
  1. Require to use the project
const ImageProcessor = require('Path_to_index.js_here');

Additionally to test it:

$ npm test

Ideally this would actually be an npm install ImageProcessor

API Reference

class ImageProcessor()

Create an ImageProcessor object.

let IP = new ImageProcessor();

init(file)

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

Transformations

Methods of ImageProcessor to transform images.

grayscale()

Transforms the image to grayscale.

let IP = new ImageProcessor()

IP.init("image.png").then(() => {
  IP.grayscale() 
})

invert(type)

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

Tests all methods of ImageProcessor.

npm test

License

MIT © Rclodeca

About

A JavaScript library for applying a series of transformations to images.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published