mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Use previous disposal method in load_end
This commit is contained in:
parent
ce3d80e713
commit
9940c84b08
BIN
Tests/images/dispose_none_load_end.gif
Normal file
BIN
Tests/images/dispose_none_load_end.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
BIN
Tests/images/dispose_none_load_end_second.gif
Normal file
BIN
Tests/images/dispose_none_load_end_second.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
|
@ -307,6 +307,20 @@ def test_dispose_none():
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
def test_dispose_none_load_end():
|
||||||
|
# Test image created with:
|
||||||
|
#
|
||||||
|
# im = Image.open("transparent.gif")
|
||||||
|
# im_rotated = im.rotate(180)
|
||||||
|
# im.save("dispose_none_load_end.gif",
|
||||||
|
# save_all=True, append_images=[im_rotated], disposal=[1,2])
|
||||||
|
with Image.open("Tests/images/dispose_none_load_end.gif") as img:
|
||||||
|
img.seek(1)
|
||||||
|
|
||||||
|
with Image.open("Tests/images/dispose_none_load_end_second.gif") as expected:
|
||||||
|
assert_image_equal(img, expected)
|
||||||
|
|
||||||
|
|
||||||
def test_dispose_background():
|
def test_dispose_background():
|
||||||
with Image.open("Tests/images/dispose_bgnd.gif") as img:
|
with Image.open("Tests/images/dispose_bgnd.gif") as img:
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -301,13 +301,14 @@ class GifImageFile(ImageFile.ImageFile):
|
||||||
|
|
||||||
# if the disposal method is 'do not dispose', transparent
|
# if the disposal method is 'do not dispose', transparent
|
||||||
# pixels should show the content of the previous frame
|
# pixels should show the content of the previous frame
|
||||||
if self._prev_im and self.disposal_method == 1:
|
if self._prev_im and self._prev_disposal_method == 1:
|
||||||
# we do this by pasting the updated area onto the previous
|
# we do this by pasting the updated area onto the previous
|
||||||
# frame which we then use as the current image content
|
# frame which we then use as the current image content
|
||||||
updated = self._crop(self.im, self.dispose_extent)
|
updated = self._crop(self.im, self.dispose_extent)
|
||||||
self._prev_im.paste(updated, self.dispose_extent, updated.convert("RGBA"))
|
self._prev_im.paste(updated, self.dispose_extent, updated.convert("RGBA"))
|
||||||
self.im = self._prev_im
|
self.im = self._prev_im
|
||||||
self._prev_im = self.im.copy()
|
self._prev_im = self.im.copy()
|
||||||
|
self._prev_disposal_method = self.disposal_method
|
||||||
|
|
||||||
def _close__fp(self):
|
def _close__fp(self):
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user