mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 01:46:18 +03:00
fixed bug with png-images with transparency palette
This commit is contained in:
parent
79ca29f2f5
commit
1ff2b6630a
|
@ -550,11 +550,11 @@ def _save(im, fp, filename, chunk=putchunk, check=0):
|
|||
|
||||
if "transparency" in im.encoderinfo:
|
||||
if im.mode == "P":
|
||||
transparency = max(0, min(255, im.encoderinfo["transparency"]))
|
||||
alpha = b'\xFF' * transparency + b'\0'
|
||||
# limit to actual palette size
|
||||
alpha_bytes = 2**bits
|
||||
chunk(fp, b"tRNS", alpha[:alpha_bytes])
|
||||
if isinstance(im.encoderinfo["transparency"], bytes):
|
||||
chunk(fp, b"tRNS", b'\xFF' + im.encoderinfo["transparency"] + b'\0')
|
||||
else:
|
||||
transparency = max(0, min(255, im.encoderinfo["transparency"]))
|
||||
chunk(fp, b"tRNS", b'\xFF' + transparency + b'\0')
|
||||
elif im.mode == "L":
|
||||
transparency = max(0, min(65535, im.encoderinfo["transparency"]))
|
||||
chunk(fp, b"tRNS", o16(transparency))
|
||||
|
|
Loading…
Reference in New Issue
Block a user