image-filter-core
Small library that relies on webworkers to apply image transformations.
There are several modules that use image-filter-core
, such as:
- image-filters
- image-filter-brightness
- image-filter-contrast
- image-filter-grayscale
- image-filter-threshold
- image-filter-sepia
- image-filter-invert
- image-filter-gamma
- image-filter-colorize
But you can easily create your own transformation function and rely on image-filter-core
to handle the webworkers and to split the work.
Install
npm install image-filter-core --save
Methods
# getCanvas()
It returns a canvas with the given width and height
var imageFilterCore = ;var canvas = imageFilterCore;
# convertImageDataToCanvasURL()
Given a ImageData it returns the dataURL
var imageFilterCore = ;var canvasURL = imageFilterCore;
# apply()
Provide the ImageData, the transformation function, the options to be passed to the transformation function and the number of workers to split the work.
var imageFilterCore = ; imageFilterCore ;
The transform function receives ImageData, the length of data to transform and the options that the developer provided to image-fiter-core, example transformation function for the threshold effect:
{ for var i = 0; i < length; i += 4 var r = datai; var g = datai + 1; var b = datai + 2; var v = 02126 * r + 07152 * g + 00722 * b >= optionsthreshold ? 255 : 0; datai = datai + 1 = datai + 2 = v; }