Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/image-processing/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Image processing 如何在ImageMagick中使用相对偏移进行裁剪?_Image Processing_Imagemagick_Crop_Imagemagick Convert - Fatal编程技术网

Image processing 如何在ImageMagick中使用相对偏移进行裁剪?

Image processing 如何在ImageMagick中使用相对偏移进行裁剪?,image-processing,imagemagick,crop,imagemagick-convert,Image Processing,Imagemagick,Crop,Imagemagick Convert,例如,这不起作用: convert -crop '69%x27%+3%+13%' +repage source.jpg cropped.jpg 它不会导致错误,但会忽略偏移量。 显然,几何体中的偏移量只能以像素为单位 如何达到预期效果?您可以这样做: convert -crop $(convert source.jpg -format "%[fx:int(w*0.69)]x%[fx:int(h*0.27)]+%[fx:int(0.03*w)]+%[fx:int(0.13*h)]" info:

例如,这不起作用:

convert -crop '69%x27%+3%+13%' +repage source.jpg cropped.jpg
它不会导致错误,但会忽略偏移量。 显然,几何体中的偏移量只能以像素为单位


如何达到预期效果?

您可以这样做:

convert -crop $(convert source.jpg -format "%[fx:int(w*0.69)]x%[fx:int(h*0.27)]+%[fx:int(0.03*w)]+%[fx:int(0.13*h)]"  info:) +repage source.jpg cropped.jpg
尝试单独运行
$()
中的部分,以查看如何生成外部命令所需的内容

convert source.jpg -format "%[fx:int(w*0.69)]x%[fx:int(h*0.27)]+%[fx:int(0.03*w)]+%[fx:int(0.13*h)]"  info:
如果我在100x100像素的图像上运行命令的这一部分,我会得到

69x27+3+13