【问题标题】:How do I crop using relative offsets in ImageMagick?如何在 ImageMagick 中使用相对偏移量进行裁剪?
【发布时间】:2013-12-29 21:52:54
【问题描述】:

例如,这不起作用:

convert -crop '69%x27%+3%+13%' +repage source.jpg cropped.jpg

它不会导致错误,但会忽略偏移量。 显然几何中的偏移量只能以像素为单位?

如何达到想要的效果?

【问题讨论】:

    标签: image-processing imagemagick crop imagemagick-convert


    【解决方案1】:

    你可以这样做:

    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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-08-03
      • 2013-09-16
      • 2014-06-27
      • 2012-02-27
      • 2012-12-11
      • 1970-01-01
      • 1970-01-01
      • 2016-09-25
      相关资源
      最近更新 更多