mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-22 13:14:45 +03:00
GIF: Clear the buffer to the correct initial color before decoding frame 0.
This ensures that transparent pixels in the first frame data clear to transparency and not to some previously decoded frame.
This commit is contained in:
parent
68b844de74
commit
df10a72000
|
@ -286,6 +286,16 @@ class GifImageFile(ImageFile.ImageFile):
|
|||
if self.palette:
|
||||
self.mode = "P"
|
||||
|
||||
def load_prepare(self):
|
||||
super(GifImageFile, self).load_prepare()
|
||||
|
||||
if self.__frame == 0:
|
||||
# On the first frame, clear the buffer. Use the transparency index
|
||||
# if we have one, otherwise use the background index.
|
||||
default_color = self.info.get("transparency",
|
||||
self.info.get("background", 0))
|
||||
self.im.paste(default_color, (0,0, self.size[0], self.size[1]))
|
||||
|
||||
def tell(self):
|
||||
return self.__frame
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user