python - 获取图像模式 PIL Python

标签 python image python-imaging-library blending

我正在尝试将两张图片混合在一起,但我一直收到错误消息,其中一张图片的模式错误。我尝试转换此图像,但我尝试过的每种模式都只会使整个图像变白。 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/

相关文章:

python - 我编写了我的 Telegram Bot (用Python)提示用户发送图像。如何确保用户只发送图像而不发送其他内容?

image-processing - Python实现Gimp的亮度图层模式

python - 为什么使用 PIL 调整 JPEG 图像的大小会增加文件大小?

python - 为什么 PIL.Image.open() 函数对象的尺寸在转换为 numpy 数组时会发生变化

css - 你会如何定位这些图像?

python - Django URL 路由问题

python - 使复杂的列表理解成为条件

python - 从pandas数据框中同时获取最大值和具有最大值的索引

python - 日期列上的左合并在 Pandas 中表现得很奇怪

java - 使用 ExifTool 读取元数据