Skip to content

Commit

Permalink
Merge pull request #4742 from radarhere/apng_dispose
Browse files Browse the repository at this point in the history
Fixed loading non-RGBA mode APNGs with dispose background
  • Loading branch information
hugovk authored Jun 29, 2020
2 parents 4cf7c56 + cdf4936 commit 645f7f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions Tests/test_file_apng.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,13 @@ def test_apng_dispose_region():
assert im.getpixel((64, 32)) == (0, 255, 0, 255)


def test_apng_dispose_op_background_p_mode():
with Image.open("Tests/images/apng/dispose_op_background_p_mode.png") as im:
im.seek(1)
im.load()
assert im.size == (128, 64)


def test_apng_blend():
with Image.open("Tests/images/apng/blend_op_source_solid.png") as im:
im.seek(im.n_frames - 1)
Expand Down
2 changes: 1 addition & 1 deletion src/PIL/PngImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def load_end(self):
dispose = self._prev_im.copy()
dispose = self._crop(dispose, self.dispose_extent)
elif self.dispose_op == APNG_DISPOSE_OP_BACKGROUND:
dispose = Image.core.fill("RGBA", self.size, (0, 0, 0, 0))
dispose = Image.core.fill(self.im.mode, self.size)
dispose = self._crop(dispose, self.dispose_extent)
else:
dispose = None
Expand Down

0 comments on commit 645f7f2

Please sign in to comment.