mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-26 09:56:17 +03:00
Merge pull request #2115 from radarhere/progressive
Read value when checking for JPEG progressive key
This commit is contained in:
commit
a490b66335
|
@ -682,13 +682,16 @@ def _save(im, fp, filename):
|
||||||
o8(len(markers)) + marker)
|
o8(len(markers)) + marker)
|
||||||
i += 1
|
i += 1
|
||||||
|
|
||||||
# get keyword arguments
|
|
||||||
im.encoderconfig = (
|
|
||||||
quality,
|
|
||||||
# "progressive" is the official name, but older documentation
|
# "progressive" is the official name, but older documentation
|
||||||
# says "progression"
|
# says "progression"
|
||||||
# FIXME: issue a warning if the wrong form is used (post-1.1.7)
|
# FIXME: issue a warning if the wrong form is used (post-1.1.7)
|
||||||
"progressive" in info or "progression" in info,
|
progressive = info.get("progressive", False) or\
|
||||||
|
info.get("progression", False)
|
||||||
|
|
||||||
|
# get keyword arguments
|
||||||
|
im.encoderconfig = (
|
||||||
|
quality,
|
||||||
|
progressive,
|
||||||
info.get("smooth", 0),
|
info.get("smooth", 0),
|
||||||
"optimize" in info,
|
"optimize" in info,
|
||||||
info.get("streamtype", 0),
|
info.get("streamtype", 0),
|
||||||
|
@ -704,7 +707,7 @@ def _save(im, fp, filename):
|
||||||
# channels*size, this is a value that's been used in a django patch.
|
# channels*size, this is a value that's been used in a django patch.
|
||||||
# https://github.com/matthewwithanm/django-imagekit/issues/50
|
# https://github.com/matthewwithanm/django-imagekit/issues/50
|
||||||
bufsize = 0
|
bufsize = 0
|
||||||
if "optimize" in info or "progressive" in info or "progression" in info:
|
if "optimize" in info or progressive:
|
||||||
# keep sets quality to 0, but the actual value may be high.
|
# keep sets quality to 0, but the actual value may be high.
|
||||||
if quality >= 95 or quality == 0:
|
if quality >= 95 or quality == 0:
|
||||||
bufsize = 2 * im.size[0] * im.size[1]
|
bufsize = 2 * im.size[0] * im.size[1]
|
||||||
|
|
|
@ -227,12 +227,20 @@ class TestFileJpeg(PillowTestCase):
|
||||||
|
|
||||||
def test_progressive_compat(self):
|
def test_progressive_compat(self):
|
||||||
im1 = self.roundtrip(hopper())
|
im1 = self.roundtrip(hopper())
|
||||||
|
self.assertFalse(im1.info.get("progressive"))
|
||||||
|
self.assertFalse(im1.info.get("progression"))
|
||||||
|
|
||||||
|
im2 = self.roundtrip(hopper(), progressive=0)
|
||||||
|
im3 = self.roundtrip(hopper(), progression=0) # compatibility
|
||||||
|
self.assertFalse(im2.info.get("progressive"))
|
||||||
|
self.assertFalse(im2.info.get("progression"))
|
||||||
|
self.assertFalse(im3.info.get("progressive"))
|
||||||
|
self.assertFalse(im3.info.get("progression"))
|
||||||
|
|
||||||
im2 = self.roundtrip(hopper(), progressive=1)
|
im2 = self.roundtrip(hopper(), progressive=1)
|
||||||
im3 = self.roundtrip(hopper(), progression=1) # compatibility
|
im3 = self.roundtrip(hopper(), progression=1) # compatibility
|
||||||
self.assert_image_equal(im1, im2)
|
self.assert_image_equal(im1, im2)
|
||||||
self.assert_image_equal(im1, im3)
|
self.assert_image_equal(im1, im3)
|
||||||
self.assertFalse(im1.info.get("progressive"))
|
|
||||||
self.assertFalse(im1.info.get("progression"))
|
|
||||||
self.assertTrue(im2.info.get("progressive"))
|
self.assertTrue(im2.info.get("progressive"))
|
||||||
self.assertTrue(im2.info.get("progression"))
|
self.assertTrue(im2.info.get("progression"))
|
||||||
self.assertTrue(im3.info.get("progressive"))
|
self.assertTrue(im3.info.get("progressive"))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user