我正在尝试将两张图片混合在一起,但我一直收到错误消息,其中一张图片的模式错误。我尝试转换此图像,但我尝试过的每种模式都只会使整个图像变白。 Python 中是否有一种方法可以使用 PIL 模块找出当前图像模式是什么?
Image.blend(img ,im ,0.05)
错误信息:
ValueError:图像模式错误
最佳答案
参见 Image Attributes在文档中:
Image.mode
:str
Image mode. This is a string specifying the pixel format used by the image. Typical values are
'1'
,'L'
,'RGB'
, or'CMYK'
. See Modes for a full list.
Image.convert
方法从现有图像创建具有给定 mode
的新 Image
。
关于python - 获取图像模式 PIL Python,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33831572/