node.js如何从图像创build缩略图?

我正在使用gm模块。这是我的代码:

gm(picture.path).thumb('250', '180', picture.thumb_path, 100, function (error) { if(error) console.log(error); }); 

但是结果大小有时是249×180。 我需要250×180

我用这个代码解决了它:

 imageMagick(picture.path) .resize('250', '180', '^') .gravity('center') .extent(250, 180) .write(picture.thumb_path, function (error) { if(error) console.log(error); });