【问题标题】:ImageMagick create image with 2 linesImageMagick 用 2 行创建图像
【发布时间】:2017-01-10 17:22:44
【问题描述】:

我最近尝试了 imagemagick 并想问我如何创建一个看起来像这样的图像(.bmp 文件):

我当前的代码如下所示:

convert -size 720x480 xc:blue \ -fill white -stroke black -strokewidth 0 -draw "line 5,20 95,20" \ myImage.bmp

但它会创建这个

【问题讨论】:

    标签: php image image-processing imagemagick imagick


    【解决方案1】:

    我可能会选择这个:

    convert xc:black[720x480\!] -size 100x5 \
       \( xc:lime xc:blue -append -write MPR:stripe \) -geometry +165+400 -composite \
      MPR:stripe -geometry +295+400 -composite \
      MPR:stripe -geometry +425+400 -composite result.png
    

    有趣部分是第二行,我在其中创建了一个浅绿色矩形和一个相同大小的蓝色矩形 (-append),并将其保存在名为 @ 的 MPR(Magick Persistent Register)中987654325@,然后我重新使用它来制作每个后续的条带。

    或者这个:

    convert -size 720x480 xc:black -strokewidth 5 \
      -stroke lime                                \
      -draw "line 165,400 265,400" -draw "line 295,400 395,400" -draw "line 425,400 525,400" \
      -stroke blue                                \
      -draw "line 165,405 265,405" -draw "line 295,405 395,405" -draw "line 425,405 525,405" myImage.bmp
    

    【讨论】:

    • 嗨,我需要那些反斜杠吗?
    • 它在您的操作系统/shell 上解除。你在bash做。
    • 你能解释一下为什么你有 4 个值吗?我不知何故感到困惑,例如 this 165,400 265,400
    • -draw line 命令采用 X & Y 值作为行首,另一个 X & Y 值作为行尾。
    【解决方案2】:

    您的命令中有一些垃圾,但它已经完成了您的要求 - 在蓝色背景上画一条黑线。

    这应该让你开始:

    convert -size 720x480 xc:black -strokewidth 5 -stroke green -fill none -draw "line 50,200 95,200" -stroke blue -draw "line 50,205 95,205" myImage.bmp
    

    【讨论】:

      猜你喜欢
      • 2014-06-11
      • 2018-07-14
      • 1970-01-01
      • 1970-01-01
      • 2013-07-25
      • 2012-01-11
      • 2017-01-23
      • 2011-02-16
      • 1970-01-01
      相关资源
      最近更新 更多