如何在“绘制矩形"命令中使用imagemagick属性? [英] How can I use imagemagick attributes in the draw rectangle command?

查看:167
本文介绍了如何在“绘制矩形"命令中使用imagemagick属性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用convert [1]在图像的整个宽度上绘制一个矩形.我正在尝试使用 ImageMagick属性来实现此目的.

I am trying to draw a rectangle across the full width of an image with convert [1]. I am trying to use ImageMagick Attributes to accomplish this.

我使用的命令是这样:

convert ImageFile -fill black -stroke black -draw "rectangle 0,0 %[w],42" ImageFileNew

我得到的输出是:

convert: NonconformingDrawingPrimitiveDefinition `rectangle' @ error/draw.c/DrawImage/3271.

使用调试:

convert ImageFile -fill black -stroke black -draw "rectangle 0,0 %[w],42" ImageFileNew

我得到:

2016-07-27T14:55:37+02:00 0:00.047 0.047u 7.0.2 Draw CONVERT[6660]: draw.c/DrawImage/1755/Draw
  begin draw-image
2016-07-27T14:55:37+02:00 0:00.047 0.047u 7.0.2 Draw CONVERT[6660]: draw.c/DrawImage/3207/Draw
  rectangle 0,0
2016-07-27T14:55:37+02:00 0:00.047 0.047u 7.0.2 Draw CONVERT[6660]: draw.c/DrawImage/3258/Draw
  end draw-image
CONVERT: NonconformingDrawingPrimitiveDefinition `rectangle' @ error/draw.c/DrawImage/3271.

我不想使用临时文件,并且希望在修剪页面重整后最终使用它.如果可以在此命令中使用属性,我也想用公式替换'42'.

I do not want to use a temporary file and I want to use this eventually after a trim repage. I would also like to replace the '42' with a formula if it is possible to use attributes in this command.

我想的问题是,是否支持该命令(如果不支持,为什么不支持H)?

I guess the question is if this is supported( and if not then why the H not)?

[1]版本:ImageMagick 7.0.2-5 Q16 x64 2016-07-22 http://www.imagemagick. org

[1] Version: ImageMagick 7.0.2-5 Q16 x64 2016-07-22 http://www.imagemagick.org

推荐答案

我想的问题是,是否支持该命令(如果不支持,为什么不支持H)?

I guess the question is if this is supported( and if not then why the H not)?

应该支持它,但是我建议使用fx:协议来计算值.

It should be supported, but I would suggest using the fx: protocol to calculate the values.

convert rose: -fill red \
       -draw 'rectangle 0 0 %[fx:w] %[fx:h]' \
       out_fill.png

我想您会认为NonconformingDrawingPrimitiveDefinition是您开始画在真实的像素.请记住,列/行索引从0开始,然后到nth - 1.

I would guess you're seeing NonconformingDrawingPrimitiveDefinition as your starting to draw outside of the range of the authentic pixels. Remember that column / row index start at 0, and got to nth - 1.

convert rose: -fill red -stroke black -strokewidth 2 \
              -draw 'rectangle 0 0 %[fx:w-1] %[fx:h-1]' \
              out_stroke.png

这篇关于如何在“绘制矩形"命令中使用imagemagick属性?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆