如何通过命令行将图像转换为灰度?[关闭]


Answers:


155

如果已imagemagick安装,

convert source.jpg -colorspace Gray destination.jpg (true grayscale only)
convert source.jpg -monochrome destination.jpg (true black and white)
convert source.jpg -separate destination.jpg (separate into gray channels)

如果您不担心丢失原始文件:mogrify -colorspace Gray file


但是,这些方法实际上都没有将AxBx3 RGB图像转换为AxBx1单通道灰度图像。
Subin Sebastian

分开对我来说很棒。
Tiago Franco

14

使用以下之一:-monochrome或()-colorspace gray选项。imagemagickconvert

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.