【问题标题】:Can you help me get rid of an intermediary output in my imagemagick convert commands?您能帮我摆脱 imagemagick 转换命令中的中间输出吗?
【发布时间】:2016-04-25 20:57:32
【问题描述】:

我在 bash 中有以下 convert 命令。

    convert "$WALLPAPER1" -resize "${H[0]}"x"${V[0]}"^ -gravity center -crop "${H[0]}"x"${V[0]}"+0+0 "$WALLPAPERS/.temp1.jpg"
    convert "$WALLPAPER2" -resize "${H[1]}"x"${V[1]}"^ -gravity center -crop "${H[1]}"x"${V[1]}"+0+0 jpg:- |
    convert "$WALLPAPERS/.temp1.jpg" - +append "$WALLPAPERS/.temp.jpg"

有没有办法摆脱"$WALLPAPERS/.temp1.jpg" 中介?那么有没有办法将第一个convert 的输出传递到第三个convert 的输入?

【问题讨论】:

  • 也许你可以使用process-groups,比如{ convert WP1 ... ; convert WP2 ...; } | convert WP/temp1.jpg - ...?进程组(在{ ...; ...; ...n;} 内部定义)组合所有标准输出并将其呈现给管道中的下一个读取器。祝你好运。
  • 有趣...我找到了一种将我的中介写入 memory-program-registers 调用 convert 一次的方法。我将研究process-groups 并尝试看看哪个更有效&& 直观。

标签: bash imagemagick-convert


【解决方案1】:
convert "$WALLPAPER1" -resize "${H[0]}"x"${V[0]}"^ -gravity center -crop "${H[0]}"x"${V[0]}"+0+0 -write mpr:temp1 +delete \
"$WALLPAPER2" -resize "${H[1]}"x"${V[1]}"^ -gravity center -crop "${H[1]}"x"${V[1]}"+0+0 -write mpr:temp2 +delete \
-gravity north mpr:temp1 mpr:temp2 +append "$WALLPAPERS/.temp.jpg"

没有必要进行 3 次转换调用。您可以写入 memory-program-register (mpr),而不是写入文件,然后稍后再调用。 +delete 删除原始图像。

【讨论】:

    猜你喜欢
    • 2022-06-11
    • 2017-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-12-07
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多