mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-11 04:07:21 +03:00
Setting transparency value to 0 when the tRNS contains only null byte(s)
This commit is contained in:
parent
77f7cfd370
commit
e317a729f3
|
@ -71,6 +71,7 @@ _MODES = {
|
||||||
|
|
||||||
|
|
||||||
_simple_palette = re.compile(b'^\xff+\x00\xff*$')
|
_simple_palette = re.compile(b'^\xff+\x00\xff*$')
|
||||||
|
_null_palette = re.compile(b'^\x00*$')
|
||||||
|
|
||||||
# Maximum decompressed size for a iTXt or zTXt chunk.
|
# Maximum decompressed size for a iTXt or zTXt chunk.
|
||||||
# Eliminates decompression bombs where compressed chunks can expand 1000x
|
# Eliminates decompression bombs where compressed chunks can expand 1000x
|
||||||
|
@ -350,6 +351,8 @@ class PngStream(ChunkStream):
|
||||||
i = s.find(b"\0")
|
i = s.find(b"\0")
|
||||||
if i >= 0:
|
if i >= 0:
|
||||||
self.im_info["transparency"] = i
|
self.im_info["transparency"] = i
|
||||||
|
elif _null_palette.match(s):
|
||||||
|
self.im_info["transparency"] = 0
|
||||||
else:
|
else:
|
||||||
self.im_info["transparency"] = s
|
self.im_info["transparency"] = s
|
||||||
elif self.im_mode == "L":
|
elif self.im_mode == "L":
|
||||||
|
|
Loading…
Reference in New Issue
Block a user