如何组合这两个 imagemagick 转换命令?

How can I combine these two imagemagick convert commands?

如何组合以下两个 imagemagick convert 命令?

  1. convert inverted.png -transparent white -negate temp.png
  2. convert standard.png temp.png -composite final.png

我无法弄清楚语法,但我敢肯定当我看到答案时我会踢自己。

你有几个选择。

首先,你可以先加载倒置图像并取反,然后加载第二个并交换顺序:

convert inverted.png -transparent white -negate standard.png +swap -composite result.png

或者,您可以按正确的顺序加载它们,但使用括号确保只有第二个被取反:

convert standard.png                             \
   \( inverted.png -transparent white -negate \) \
   -composite result.png

顺便说一句,这是旧的 v6 语法,您现在应该使用 v7,即:

magick inverted.png -transparent white -negate standard.png +swap -composite result.png