修剪将根据角像素删除边框,
Extent和Gravity将使图像具有一定的大小并相应地对齐,
另请参阅几何参数,
convert -trim source.png trim.png
convert -extent 800x600 -gravity center trim.png frame.png

以下是显示图像的尺寸:
- 来源:722 x 480
- 修剪:640 x 400
- 画幅:800x 600
编辑
这将调整图像的大小以适合 800 像素宽,如果它更小,则使其高度为 600:

convert -resize 800x600^ -extent 800x600 -gravity center trim.png resize.png
有关所有详细信息,请参阅http://www.imagemagick.org/Usage/resize/#fill,特别是您应该测试它在肖像图像上的表现。
此外,如果您在resize
参数中删除 800 ,它将适合其高度:

convert -resize x600^ -extent 800x600 -gravity center trim.png resize.png
编辑 2
您必须将插入符号与轴之一一起使用:
convert -resize 1200^ -extent 1200x600 -gravity center trim.png resize1.png

如您所见,顶部和底部已被修剪,并且图像已根据其宽度进行拟合。