Ger*_*ery 3 bash shell imagemagick image-processing imagemagick-convert
我有以下图像:
test PNG 1366x655 1366x655+0+0 8-bit sRGB 286KB 0.000u 0:00.000
Run Code Online (Sandbox Code Playgroud)
我需要从图像的边缘将其切成这样:
top: 140 px
bottom: 140 px
left: 180 px
right: 60 px
Run Code Online (Sandbox Code Playgroud)
是否有单行命令行来执行此操作convert?
您可以组合两个-crops:
#left,top right,bottom
convert test.png -crop +180+140 -crop -60-140 cropped.png
Run Code Online (Sandbox Code Playgroud)
解决方案that other guy非常巧妙。标准方法是使用 -chop。但这意味着 4 次调用,因为要删除的大小不对称。所以在 ImageMagick 中使用 -chop,你可以这样做
convert text.png -gravity north -chop 0x180 -gravity east -chop 60x0 -gravity south -chop 0x140 -gravity west -chop 140x0 cropped.png
Run Code Online (Sandbox Code Playgroud)
请参阅http://www.imagemagick.org/Usage/crop/#chop
当左/右、上/下或四周对称时,另请参见 -shave。http://www.imagemagick.org/Usage/crop/#shave