Linux 如何通过命令行将图像转换为灰度?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7708368/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I convert an image to grayscale via the command line?
提问by cwd
How can I use sips
, imagemagic
, or another tool to convert an image to black and white (grayscale) via the command line?
如何使用sips
、imagemagic
或其他工具通过命令行将图像转换为黑白(灰度)?
采纳答案by mark
If you have imagemagick
installed,
如果你已经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)
If you don't care about losing the original file: mogrify -colorspace Gray file
.
如果您不在乎丢失原始文件:mogrify -colorspace Gray file
.
回答by imm
use one of: -monochrome
or -colorspace gray
options for imagemagick
(convert
).
使用以下选项之一:-monochrome
或( )-colorspace gray
选项。imagemagick
convert