首页 > 解决方案 > 使用 pgmagick 在 Python 中调整图像级别

问题描述

我正在尝试在 Windows 7、Python 3.5.1 上使用 pgmagick 调整图像级别。

我提出的所有变体要么以几乎完全白色的图像结束,要么出现以下错误:

Traceback (most recent call last):
  File "test.py", line 7, in <module>
    im.level('48%,0.5,52%')
Boost.Python.ArgumentError: Python argument types in
    Image.level(Image, str)
did not match C++ signature:
    level(class Magick::Image {lvalue}, double, double, double)

我还在 Photoshop 上测试了我的关卡设置,所以它们是有意义的并且不会产生白色图片。这是我的代码:

from pgmagick import Image

im = Image('image.jpg')
im.level('48%,0.5,52%')       # not working
# im.level('48%', 0.5, '52%') # not working
# im.level(48,0.5,52)         # no error but picture almost completely white

请注意,我可以使用运行以下代码的 Node.js 调整图像级别:

gm('image.jpg')
.level('48%', 0.5, '52%')

非常感谢任何帮助和想法!

标签: pythongraphicsmagickpgmagick

解决方案


推荐阅读