Install:
npm install epeg
Downsize:
var epeg = require("epeg");
image = new epeg.Image({path: "./test.jpg"}))
image.downsize(100, 100).saveTo("./output.jpg");
Crop:
var epeg = require("epeg");
image = new epeg.Image({path: "./test.jpg"}))
image.crop(200, 200, 100, 100).saveTo("./output.jpg");
Both can take an optional 'quality' parameter between 1 and 100 (default is 85):
var epeg = require("epeg");
image = new epeg.Image({path: "./test.jpg"}))
image.downsize(100, 100, 50).saveTo("./ugly.jpg");
You can also use buffers as I/O:
var fs = require("fs");
var epeg = require("epeg");
fs.readFile("./test.jpg", function(err, data) {
var image = new epeg.Image({data: data});
buffer = image.downsize(100, 100).process();
fs.writeFileSync("./output.jpg", buffer);
}