简体   繁体   English

PythonMagick:将RGB转换为灰度

[英]PythonMagick: Convert RGB to Grayscale

I found this description link_1 , link_2 . 我发现此描述为link_1link_2

Trying to do so 尝试这样做

import PythonMagick
img = PythonMagick.Image('file.png')
img.colorSpace('GRAYColorspace')

Return this 返回这个

ArgumentError: Python argument types in
    Image.colorSpace(Image, str)
did not match C++ signature:
    colorSpace(class Magick::Image {lvalue})
    colorSpace(class Magick::Image {lvalue}, enum MagickCore::ColorspaceType)

How to do it? 怎么做?

PythonMagick already supports ColorSpaceTypes since version 9.10 从9.10版本开始,PythonMagick已经支持ColorSpaceTypes

http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=25229 http://www.imagemagick.org/discourse-server/viewtopic.php?f=2&t=25229

Here's an example to accomplish what you're trying to do: 这是一个示例,可以完成您要执行的操作:

import PythonMagick as pm
img = pm.Image('file.png')
img.colorSpace(pm.ColorspaceType.GRAYColorspace)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM