如何使用 ImageMagick 仅裁剪图像的左侧和右侧

How can I crop only left and right sides of an image using ImageMagic

如何在不知道图像宽度的情况下从图像的左侧和右侧删除特定数量的像素:

我试过了:

convert img.png -crop +200 result.png

但它只从左侧移除

可以用负数从右边去掉:

convert img.png -crop +200 +repage -crop -200 result.png

你可以像这样使用-shave从左右两边去掉200个像素:

convert input.png -shave 200x0 result.png

顶部和底部像这样:

convert input.png -shave 0x200 result.png