From 047832c6c667c473cd5013e2fba1ab3f5bd291bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20J=C3=B8rgen=20Solberg?= Date: Thu, 3 Jul 2014 19:01:18 +0200 Subject: [PATCH] only update the disposal_method if it not 'unspecified' --- PIL/GifImagePlugin.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/PIL/GifImagePlugin.py b/PIL/GifImagePlugin.py index 7eeaae646..cb96b9c95 100644 --- a/PIL/GifImagePlugin.py +++ b/PIL/GifImagePlugin.py @@ -144,8 +144,14 @@ class GifImageFile(ImageFile.ImageFile): self.info["duration"] = i16(block[1:3]) * 10 # disposal method - find the value of bits 4 - 6 - self.disposal_method = 0b00011100 & flags - self.disposal_method = self.disposal_method >> 2 + dispose_bits = 0b00011100 & flags + dispose_bits = dispose_bits >> 2 + if dispose_bits: + # only set the dispose if it is not + # unspecified. I'm not sure if this is + # correct, but it seems to prevent the last + # frame from looking odd for some animations + self.disposal_method = dispose_bits elif i8(s) == 255: # # application extension