mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-09 08:00:49 +03:00
Merge pull request #3501 from pirate486743186/patch-2
Add APNG extension to PNG plugin
This commit is contained in:
commit
454fdd7800
BIN
Tests/images/iss634.apng
Normal file
BIN
Tests/images/iss634.apng
Normal file
Binary file not shown.
After Width: | Height: | Size: 342 KiB |
|
@ -6,6 +6,12 @@ from io import BytesIO
|
||||||
import zlib
|
import zlib
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
|
try:
|
||||||
|
from PIL import _webp
|
||||||
|
HAVE_WEBP = True
|
||||||
|
except ImportError:
|
||||||
|
HAVE_WEBP = False
|
||||||
|
|
||||||
codecs = dir(Image.core)
|
codecs = dir(Image.core)
|
||||||
|
|
||||||
|
|
||||||
|
@ -579,6 +585,13 @@ class TestFilePng(PillowTestCase):
|
||||||
self.assertIsInstance(im.text, dict)
|
self.assertIsInstance(im.text, dict)
|
||||||
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
ImageFile.LOAD_TRUNCATED_IMAGES = False
|
||||||
|
|
||||||
|
@unittest.skipUnless(HAVE_WEBP and _webp.HAVE_WEBPANIM,
|
||||||
|
"WebP support not installed with animation")
|
||||||
|
def test_apng(self):
|
||||||
|
im = Image.open("Tests/images/iss634.apng")
|
||||||
|
expected = Image.open("Tests/images/iss634.webp")
|
||||||
|
self.assert_image_similar(im, expected, 0.23)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or macOS")
|
@unittest.skipIf(sys.platform.startswith('win32'), "requires Unix or macOS")
|
||||||
class TestTruncatedPngPLeaks(PillowLeakTestCase):
|
class TestTruncatedPngPLeaks(PillowLeakTestCase):
|
||||||
|
|
|
@ -526,6 +526,19 @@ class PngStream(ChunkStream):
|
||||||
|
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
# APNG chunks
|
||||||
|
def chunk_acTL(self, pos, length):
|
||||||
|
s = ImageFile._safe_read(self.fp, length)
|
||||||
|
return s
|
||||||
|
|
||||||
|
def chunk_fcTL(self, pos, length):
|
||||||
|
s = ImageFile._safe_read(self.fp, length)
|
||||||
|
return s
|
||||||
|
|
||||||
|
def chunk_fdAT(self, pos, length):
|
||||||
|
s = ImageFile._safe_read(self.fp, length)
|
||||||
|
return s
|
||||||
|
|
||||||
|
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# PNG reader
|
# PNG reader
|
||||||
|
@ -892,6 +905,7 @@ def getchunks(im, **params):
|
||||||
Image.register_open(PngImageFile.format, PngImageFile, _accept)
|
Image.register_open(PngImageFile.format, PngImageFile, _accept)
|
||||||
Image.register_save(PngImageFile.format, _save)
|
Image.register_save(PngImageFile.format, _save)
|
||||||
|
|
||||||
Image.register_extension(PngImageFile.format, ".png")
|
Image.register_extensions(PngImageFile.format, [".png", ".apng"])
|
||||||
|
|
||||||
Image.register_mime(PngImageFile.format, "image/png")
|
Image.register_mime(PngImageFile.format, "image/png")
|
||||||
|
Image.register_mime(PngImageFile.format, "image/apng")
|
||||||
|
|
Loading…
Reference in New Issue
Block a user