1.0.4 • Published 7 years ago
ioptimizer v1.0.4
iOptimizer

iOptimizer provides easy way to compress images even from base64 code. It has 3 simple methods which allow you to set dimensions, scale or change quality of your image!
Install
npm install ioptimizerBasic usage
iOptimizer supports 4 file types jpg, jpeg, png and bmp. Just choose one of three methods, provide an image (file or base64 code), values and callback function which will receive new image object!
DEMO
You can quickly try it for yourself here!
Usage example
import iOptimizer from 'ioptimizer';
callback = (image) => {
console.log(image);
};
// set dimensions:
iOptimizer.setDimensions(image, 1280, 800, this.callback);
// set quality:
iOptimizer.setQuality(image, 50, this.callback);
// scale:
iOptimizer.scale(image, 50, this.callback);API
setDimensions(image, width, height, callback)
imageString - image file or base64 code. Supported file types arejpg,jpeg,pngandbmp.widthNumber - new image width.heightNumber - new image height.callbackFunction - callback function which receives new image object.
setQuality(image, quality, callback)
imageString - image file or base64 code. Supported file types arejpg,jpeg,pngandbmp.qualityNumber - quality value, should be between0 - 100.callbackFunction - callback function which receives new image object.
scale(image, quality, callback)
imageString - image file or base64 code. Supported file types arejpg,jpeg,pngandbmp.scaleNumber - scale value, should be between0 - 100.callbackFunction - callback function which receives new image object.