Wal*_*ner 4 linux bash ubuntu imagemagick imagemagick-convert
我通过阅读ImageMagick 文档中有关文本的理解,该@-符号读取标准输入的内容。
因此,这应该是渲染 Hello World 的一种相当简单的方法。
printf "Hello\nWorld" |
convert \
-size 1280x100 \
-background '#0000FF10' \
-density 90 \
-gravity Center \
-fill black \
-font Helvetica \
caption:@- \
test.png
Run Code Online (Sandbox Code Playgroud)
在 OS X 10.11.5 上通过HomeBrew,这可以工作,使用convert版本:ImageMagick 6.9.4-3 Q16 x86_64 2016-05-20。
然而,在 Ubuntu 16.04 LTS 上,相同的命令不起作用,使用convert版本:ImageMagick 6.8.9-9 Q16 x86_64 2016-06-01。事实上,它从字面上呈现了 stdin 运算符。
我在 Google 上唯一能找到的看起来像这个问题的文章是2015 年 10 月的这篇文章,其中对 ImageMagick 6.9.2-5 Beta 进行了修补以修复类似的问题。
问题:我是否没有正确转义它,ImageMagick 中是否确实存在问题,或者我的 Linux 发行版是否使用了带有错误的 ImageMagick 历史版本,而我需要从源代码构建?
经过多次实验之后
解决了 ...?在 Ubuntu 机器上从源代码构建 ImageMagick 7.0.2,上面的命令按预期工作。有更好的解决方案吗?
小智 5
无需从源代码构建。只需将 @- 替换为“`tee`”:
printf "Hello\nWorld" |
convert \
-size 1280x100 \
-background '#0000FF10' \
-density 90 \
-gravity Center \
-fill black \
-font Helvetica \
caption:"`tee`" \
test.png
Run Code Online (Sandbox Code Playgroud)
在完成转换命令之前,“tee”将首先执行并“处理”stdin。
| 归档时间: |
|
| 查看次数: |
957 次 |
| 最近记录: |