-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Open
Description
This library doesn't recognize transparent pixels as such in images loaded from 1-bit PNGs with a 'tRNS' chunk. The following example loads an 8×2 image, where the first row is transparent and the second row is black. Despite this, when retrieving a pixel from the first row, the alpha component is 255, and not 0 (transparent) as expected.
import base64
import io
import PIL.Image
# 8×2 image: first row transparent, second row black
bio=io.BytesIO(base64.b64decode(
b'iVBORw0KGgoAAAANSUhEUgAAAAgAAAACAQAAAABN'+\
b'76BAAAAAAnRSTlMAAQGU/a4AAAAMSURBVHicY/jPwAAAAwEBAMn+'+\
b'ku8AAAAASUVORK5CYII='))
pi=PIL.Image.open(bio)
# Note: Image has mode '1' and a 'tRNS' chunk
pi2=pi.convert("RGBA")
# alpha component of first row's pixel should equal 0,
# but is 255 instead
print(pi2.getpixel([0,0]))Metadata
Metadata
Assignees
Labels
No labels