如何将就地批量 PNG 从灰度转换为 RGB?
How to convert in-place batch of PNG from grayscale to RGB?
所以,我想将许多 PNG 从灰度转换为 RGB,类似于
但是,那里的给定命令不适用于 PNG。此外,那是 convert
我读到要处理图像 就地 必须使用 mogrify
。我该如何使用它?
所以,这都是 a bug and a feature 的 imagemagic。引用 feature 部分:
It turns out ImageMagick tries to set to PNG8 based on image content even if the file was previously PNG24 or PNG32
因此,如果你想每张图片有 3 个通道,你必须设置 png24
格式(3
通道 x
8
bits/channel).
所以解决方案是:
# for a single image, with a different output
convert input.png -type TrueColor png24:output.png
# for a batch of images, IN_PLACE !!! BE VERY CAREFUL
mogrify -define png:format=png24 -type TrueColor *.png
必须意识到 mogrify
会 就地 修改它们,因此请确保这是您想要的,因为无法恢复原始图像。
所以,我想将许多 PNG 从灰度转换为 RGB,类似于
但是,那里的给定命令不适用于 PNG。此外,那是 convert
我读到要处理图像 就地 必须使用 mogrify
。我该如何使用它?
所以,这都是 a bug and a feature 的 imagemagic。引用 feature 部分:
It turns out ImageMagick tries to set to PNG8 based on image content even if the file was previously PNG24 or PNG32
因此,如果你想每张图片有 3 个通道,你必须设置 png24
格式(3
通道 x
8
bits/channel).
所以解决方案是:
# for a single image, with a different output
convert input.png -type TrueColor png24:output.png
# for a batch of images, IN_PLACE !!! BE VERY CAREFUL
mogrify -define png:format=png24 -type TrueColor *.png
必须意识到 mogrify
会 就地 修改它们,因此请确保这是您想要的,因为无法恢复原始图像。