How to use https://github.com/rsms/node-imagemagick add more white space around the image ?
example original image is width:300, height:100, I want to generate new image is width: 600, height: 200 the original image is in center stay original size, add white space around to become new image..
I tried below code but this make the original image become 600*200 ... how to solve it?
function cropGravity(srcFilePath, dstFilePath, resizeWidth, resizeHeight, quality, gravity) {
return new Promise(function (resolve, reject){
im.crop({
srcPath: srcFilePath,
dstPath: dstFilePath,
width: resizeWidth,
height: resizeHeight,
quality: quality,
gravity: gravity
}, function(error, stdout, stderr){
if (error != null) {
console.log(error)
reject(error);
} else {
resolve(dstFilePath);
}
});
});
};
...
var resizeWidth = 600;
var resizeHeight = 200;
var quality = 1;
var gravity = 'Center';
cropGravity(srcFilePath, dstFilePath, resizeWidth, resizeHeight, quality, gravity)
I really don't speak
node, but it will likely be similar to this: