How can you inspect opacity independently of color?

getchannel extracts a named band as a single-band image, including alpha from RGBA.

Pixel experiment and interpretation

A saturated red pixel can be nearly transparent. Reading red would confuse color intensity with coverage; read alpha to inspect coverage.

from PIL import Image

Image.new('RGBA',(1,1),(255,0,0,12)).getchannel('A').getpixel((0,0))

Result 12

中文

怎样单独检查前景的不透明程度?

getchannel 提取一个命名通道为单通道图像,可用于检查 RGBA 的 alpha。

像素实验与适用边界

红色像素也可以接近透明。只看红通道会误把颜色强度当作前景置信度;示例读出的是覆盖程度。

from PIL import Image

Image.new('RGBA',(1,1),(255,0,0,12)).getchannel('A').getpixel((0,0))

结果 12

References / 参考来源

Keep reading / 继续阅读