GIF: Clear to transparency rather than background if available.

Background dispose should prefer the transparency color over the
background color, if there is one.  This matches other decoders
and makes transparent_dispose.gif decode correctly.
This commit is contained in:
Glenn Maynard 2018-10-23 23:09:47 -05:00 committed by Andrew Murray
parent df10a72000
commit b5806c7e15

View File

@ -258,9 +258,10 @@ class GifImageFile(ImageFile.ImageFile):
# do not dispose or none specified # do not dispose or none specified
self.dispose = None self.dispose = None
elif self.disposal_method == 2: elif self.disposal_method == 2:
# replace with background colour # replace with transparency if there is one, otherwise
self.dispose = Image.core.fill("P", self.size, # background colour
self.info["background"]) bg = info.get("transparency", self.info["background"])
self.dispose = Image.core.fill("P", self.size, bg)
else: else:
# replace with previous contents # replace with previous contents
if self.im: if self.im: