使用ImageMagick将图像放在较大的画布中

问题描述:

开始使用ImageMagic并试图找到一种方法来执行此操作...如果图像高度小于50像素或宽度为50像素,我想将其放置在水平/垂直方向(未缩放)在白色背景上的新50x50像素画布的中心 - 并将其保存为新图像。任何人都知道ImageMagick是否可以实现这一目标?谢谢!

Getting started with ImageMagic and trying to find a way to do this... If an image is less than 50 pixels tall or 50 pixels wide, I'd like to place it (un-scaled) in the horizontal/vertical center of a new 50x50 pixel canvas on top of a white background - and save that as the new image. Anyone know if this is possible with ImageMagick? Thanks!

我用-extent来做到这一点:

I used -extent to do this:

convert input.jpg -gravity center -background white -extent 50x50  output.jpg