How to achive zoom crop with node js's gm lib.
zoom crop means image will be auto zoomed to fit best width and height. so image will be of exact width heights without scaling, stretching or leaving blank space in either side.
this is the code what i am trying so far
// resize
var options={
w:100,
h:150,
c:null
};
var image=gm(imagePath);
// resize
image.gravity('Center');
//image.extent(options.w, options.h)
image.resize(options.w,options.h);
var saveImage=function(){
image.write(saveImagePath, function (err) {
if (err){
console.log(err);
next(connection,true);
} else {
var img = fs.readFileSync(saveImagePath);
res.writeHead(200, {'Content-Type': 'image/'+type});
res.end(img, 'binary');
}
});
};
saveImage();