mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-01-12 02:06:18 +03:00
Added test cases to exhibit issues with custom qtables
This commit is contained in:
parent
55c20731d1
commit
7872501c5b
|
@ -303,6 +303,15 @@ class TestFileJpeg(PillowTestCase):
|
|||
filename = "Tests/images/junk_jpeg_header.jpg"
|
||||
Image.open(filename)
|
||||
|
||||
def _n_qtables_helper(self, n, test_file):
|
||||
im = Image.open(test_file)
|
||||
f = self.tempfile('temp.jpg')
|
||||
im.save(f, qtables=[[n]*64]*n)
|
||||
im = Image.open(f)
|
||||
self.assertEqual(len(im.quantization), n)
|
||||
reloaded = self.roundtrip(im, qtables="keep")
|
||||
self.assertEqual(im.quantization, reloaded.quantization)
|
||||
|
||||
def test_qtables(self):
|
||||
im = Image.open("Tests/images/hopper.jpg")
|
||||
qtables = im.quantization
|
||||
|
@ -359,6 +368,15 @@ class TestFileJpeg(PillowTestCase):
|
|||
1: standard_chrominance_qtable
|
||||
}), 30)
|
||||
|
||||
self._n_qtables_helper(1, "Tests/images/hopper_gray.jpg")
|
||||
self._n_qtables_helper(1, "Tests/images/pil_sample_rgb.jpg")
|
||||
self._n_qtables_helper(2, "Tests/images/pil_sample_rgb.jpg")
|
||||
self._n_qtables_helper(3, "Tests/images/pil_sample_rgb.jpg")
|
||||
self._n_qtables_helper(1, "Tests/images/pil_sample_cmyk.jpg")
|
||||
self._n_qtables_helper(2, "Tests/images/pil_sample_cmyk.jpg")
|
||||
self._n_qtables_helper(3, "Tests/images/pil_sample_cmyk.jpg")
|
||||
self._n_qtables_helper(4, "Tests/images/pil_sample_cmyk.jpg")
|
||||
|
||||
# not a sequence
|
||||
self.assertRaises(Exception, lambda: self.roundtrip(im, qtables='a'))
|
||||
# sequence wrong length
|
||||
|
|
Loading…
Reference in New Issue
Block a user