如何使用 imagemagick 在图像周围添加更多白色 space

How to use imagemagick add more white space around the image

如何使用https://github.com/rsms/node-imagemagick在图像周围添加更多的白色space? 例如原始图像是 width:300, height:100,我要生成新图像是 width: 600, height: 200 原始图像在中心保持原始大小,在周围添加白色 space 成为新图像..

我试过下面的代码,但这会使原始图像变成 600*200 ...如何解决?

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)

我真的不会说话node,但大概会是这样:

im.convert(['input.jpg', '-gravity', 'center', '-background','white', '-extent', '600x200','result.jpg'], 
function(err, stdout){
  if (err) throw err;
  console.log('stdout:', stdout);
});