ImageMagick修剪图片(crop)

ImageMagick修剪图片(crop)

Content #

Crop的含义是从原始图片中截取某个矩形。比如:

convert -crop 1104x372+58+100 input.jpg output.jpg

表示要截取的矩形的宽为1104,高为372。矩形的左上角位置在原始图片的 (58, 100)位置。

在处理png图片时,可能需要执行如下操作:

convert +repage a.png b.png

这个操作会将 virtual canvas meta-data 完全重置。

It might be necessary to +repage the image prior to cropping the image to ensure the crop coordinate frame is relocated to the upper-left corner of the visible image. Similarly you may want to use +repage after cropping to remove the page offset that will be left behind. This is especially true when you are going to write to an image format such as PNG that supports an image offset.

Viewpoint #

From #

https://www.imagemagick.org/script/command-line-options.php#crop