mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 17:06:16 +03:00
Add tests for loading/saving of 16-bit quantization tables
This commit is contained in:
parent
b212a1eb8f
commit
2f0544b542
|
@ -446,6 +446,7 @@ class TestFileJpeg:
|
|||
assert len(im.quantization) == n
|
||||
reloaded = self.roundtrip(im, qtables="keep")
|
||||
assert im.quantization == reloaded.quantization
|
||||
assert reloaded.quantization[0].typecode == 'B'
|
||||
|
||||
with Image.open("Tests/images/hopper.jpg") as im:
|
||||
qtables = im.quantization
|
||||
|
@ -544,6 +545,30 @@ class TestFileJpeg:
|
|||
with pytest.raises(ValueError):
|
||||
self.roundtrip(im, qtables=[[1, 2, 3, 4]])
|
||||
|
||||
def test_load_16bit_qtables(self):
|
||||
with Image.open("Tests/images/hopper_16bit_qtables.jpg") as im:
|
||||
assert len(im.quantization) == 2
|
||||
assert len(im.quantization[0]) == 64
|
||||
assert max(im.quantization[0]) > 255
|
||||
|
||||
def test_save_multiple_16bit_qtables(self):
|
||||
with Image.open("Tests/images/hopper_16bit_qtables.jpg") as im:
|
||||
im2 = self.roundtrip(im, qtables='keep')
|
||||
assert im.quantization == im2.quantization
|
||||
|
||||
def test_save_single_16bit_qtable(self):
|
||||
with Image.open("Tests/images/hopper_16bit_qtables.jpg") as im:
|
||||
im2 = self.roundtrip(im, qtables=[im.quantization[0]])
|
||||
assert len(im2.quantization) == 1
|
||||
assert im2.quantization[0] == im.quantization[0]
|
||||
|
||||
def test_save_low_quality_baseline_qtables(self):
|
||||
with Image.open(TEST_FILE) as im:
|
||||
im2 = self.roundtrip(im, quality=10)
|
||||
assert len(im2.quantization) == 2
|
||||
assert max(im2.quantization[0]) <= 255
|
||||
assert max(im2.quantization[1]) <= 255
|
||||
|
||||
@pytest.mark.skipif(not djpeg_available(), reason="djpeg not available")
|
||||
def test_load_djpeg(self):
|
||||
with Image.open(TEST_FILE) as img:
|
||||
|
|
Loading…
Reference in New Issue
Block a user