Image Processor using Node Streams
This library processes images by passing a readabale stream (or file paths) and writes it into a writable stream. It uses jpegtran for jpg methods, optipng and gifsicle-stream for optimizing png & gif files, respectively. The current fallback for PNG and GIF operations uses gm.
Installation & Usage
npm install --save image-processor
var ImageProcessor = rs = fs photo = 'photos/photo2.jpg'; // Accept a readable streamvar imageProcessor = rs; // Accept a file pathvar imageProcessorFilePath = photo; //Configure options//See API below to properly configure options per methodvar opts = interlaced: true arithmetic: true ; imageProcessor;
API
-
imageProcessor.crop(w, h, x, y, callback);
imageStream; -
imageProcessor.rotate(deg, callback);
imageStream; -
imageProcessor.scale(w, h, callback);
imageStream; -
imageProcessor.resize(w, h, callback);
imageStream; -
imageProcessor.minify(callback);
imageStream; -
imageProcessor.optimize(opts, callback);
var opts =progressive: truearithmetic: true;imageStream; -
imageProcessor.getImgDimensions(callback);
imageStream;
Supported file types
- JPG / JPEG
- PNG
- GIF
- TIFF