micro-image-transformations

3.0.0 • Public • Published

micro-image-transformations (v1.0.0)

travis build PRs Welcome
An image processing microlibrary for Node and the web. Though I wrote this as a Node packages, I am targetting the web, for users who would like to modify web images.
Unittests are written in mocha and chai

Here is a link to a demo website I put together: [pending]

The npm package is currently v3.0.0 as I had to publish a few times for testing purposes.

Thank you Instrumental, your consideration means a lot to me. This project was an enjoyable learning experience!

Installation

npm install --save micro-image-transformations

For setting up browserify to use this npm pacakage, run
npm install -g browserify
Then pass the path of the js file that contains the image transform code
browserify src/image_handler.js -o bundle.js
Run this each time you make changes to the file or simply use watchify (another useful npm package).

If already installed, run npm update to check for and install new versions.

Example Usage

Suppose this js file is src/image_handler.js

  //include the 
  var imageTransformLibrary = require('micro-image-transformations');
  
  //grayscale transform
  var grayscaleImage=imageTransformLibrary.grayscale(img);
  
  //render it to canvas
  var context = document.getElementById('image-display').getContext('2d');
  context.drawImage(grayscaleImage,0,0);

Methods

  grayscale(image);  //averages values based on a luminosity equation. (humans are more sensitive to green)
  crop(image, startX, startY, cropWidth, cropHeight);  //uses cartesian coordinates (bottom left corner of image is (0,))

Supported Image Types

  • jpeg
  • png
  • gif
  • ico
  • may support additional image types like tiff and bmp (not tested)

Image Transformations Provided

  • grayscale - Turn an image into grayscale (luminosity correction algorithm used as humans are more sensitive to green)
  • crop - Crop an image.

Contributing

Clone this repository! Submit your PR and Travis will run some tests to make sure it is compliant with current standards.

Testing

In the cloned repository, to run tests, run npm test. Current tests are written in mocha and chai, testing grayscale and crop functions.

Note: eslint currently disabled due to some Travis complaints.

License

micro-image-transformations is licensed under the MIT license.

Readme

Keywords

Package Sidebar

Install

npm i micro-image-transformations

Weekly Downloads

0

Version

3.0.0

License

MIT

Unpacked Size

19.7 kB

Total Files

6

Last publish

Collaborators

  • jshi22