mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
This patch allows a JPEG image to be saved with a specific qtables
value (in dictionary format). Previously, this would throw a TypeError when checking if the qtables value was actually a preset. By adding an isStringType check, we can avoid this error.
This commit is contained in:
parent
8a8aec534b
commit
70a50907c2
|
@ -498,7 +498,7 @@ def _save(im, fp, filename):
|
|||
else:
|
||||
if subsampling in presets:
|
||||
subsampling = presets[subsampling].get('subsampling', -1)
|
||||
if qtables in presets:
|
||||
if isStringType(qtables) and qtables in presets:
|
||||
qtables = presets[qtables].get('quantization')
|
||||
|
||||
if subsampling == "4:4:4":
|
||||
|
|
|
@ -230,6 +230,13 @@ def test_quality_keep():
|
|||
assert_no_exception(lambda: im.save(f, quality='keep'))
|
||||
|
||||
|
||||
def test_qtables():
|
||||
im = Image.open("Images/lena.jpg")
|
||||
qtables = im.quantization
|
||||
f = tempfile('temp.jpg')
|
||||
assert_no_exception(lambda: im.save(f, qtables=qtables, subsampling=0))
|
||||
|
||||
|
||||
def test_junk_jpeg_header():
|
||||
# https://github.com/python-imaging/Pillow/issues/630
|
||||
filename = "Tests/images/junk_jpeg_header.jpg"
|
||||
|
|
Loading…
Reference in New Issue
Block a user