image-filters
v1.0.1
Published
Small image filters library
Downloads
18
Maintainers
Readme
image-filters
Small library to apply a transformations to a image relying on image-filter-core
handle the transformation and distribute work with webworkers.
This library is wrapper around the following smaller libraries:
- image-filter-brightness
- image-filter-color
- image-filter-colorize
- image-filter-contrast
- image-filter-gamma
- image-filters
- image-filter-invert
- image-filter-sepia
- image-filter-threshold
So if you want to use only one or two of these filters you might be better of just including them directly.
Install
npm install image-filters --save
Usage
At the moment there are three ways of usage, img element, imageData or url:
Initialization:
var imageFilter = require('image-filters');
// from a image element
var elementOne = new ImageFilter({ from: '#original' }, nWorkers);
// from image data
var elementTwo = new ImageFilter({ imageData: imageData }, nWorkers);
// from url
var elementThree = new ImageFilter({ url: "http://lorempixel.com/400/200" }, nWorkers);
Apply filters:
imageFilter
.contrast({ contrast: 50 })
.brightness({ adjustment: 50 });
Get results:
Every transformation will return as imageData, but you have the possibility to get the result appended to the DOM.
//append to html
imageFilter.append('#target');
Development
To run the samples in this module please run npm run build && npm run serve
and then access http://127.0.0.1:8080/simple/
or http://127.0.0.1:8080/editor/