diff --git a/src/PIL/GifImagePlugin.py b/src/PIL/GifImagePlugin.py index 658bee214..2f988ff43 100644 --- a/src/PIL/GifImagePlugin.py +++ b/src/PIL/GifImagePlugin.py @@ -269,9 +269,14 @@ class GifImageFile(ImageFile.ImageFile): dispose_size = (x1 - x0, y1 - y0) Image._decompression_bomb_check(dispose_size) - self.dispose = Image.core.fill( - "P", dispose_size, self.info.get("background", 0) + + # by convention, attempt to use transparency first + color = ( + frame_transparency + if frame_transparency is not None + else self.info.get("background", 0) ) + self.dispose = Image.core.fill("P", dispose_size, color) else: # replace with previous contents if self.im: