mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Merge pull request #3464 from radarhere/quality_layers
Check quality_layers type
This commit is contained in:
commit
0b881555ad
|
@ -105,6 +105,22 @@ class TestFileJpeg2k(PillowTestCase):
|
|||
im.load()
|
||||
self.assertEqual(im.size, (160, 120))
|
||||
|
||||
def test_layers_type(self):
|
||||
outfile = self.tempfile('temp_layers.jp2')
|
||||
for quality_layers in [
|
||||
[100, 50, 10],
|
||||
(100, 50, 10),
|
||||
None
|
||||
]:
|
||||
test_card.save(outfile, quality_layers=quality_layers)
|
||||
|
||||
for quality_layers in [
|
||||
'quality_layers',
|
||||
('100', '50', '10')
|
||||
]:
|
||||
self.assertRaises(ValueError, test_card.save, outfile,
|
||||
quality_layers=quality_layers)
|
||||
|
||||
def test_layers(self):
|
||||
out = BytesIO()
|
||||
test_card.save(out, 'JPEG2000', quality_layers=[100, 50, 10],
|
||||
|
|
|
@ -232,6 +232,13 @@ def _save(im, fp, filename):
|
|||
tile_size = info.get('tile_size', None)
|
||||
quality_mode = info.get('quality_mode', 'rates')
|
||||
quality_layers = info.get('quality_layers', None)
|
||||
if quality_layers is not None and not (
|
||||
isinstance(quality_layers, (list, tuple)) and
|
||||
all([isinstance(quality_layer, (int, float))
|
||||
for quality_layer in quality_layers])
|
||||
):
|
||||
raise ValueError('quality_layers must be a sequence of numbers')
|
||||
|
||||
num_resolutions = info.get('num_resolutions', 0)
|
||||
cblk_size = info.get('codeblock_size', None)
|
||||
precinct_size = info.get('precinct_size', None)
|
||||
|
|
Loading…
Reference in New Issue
Block a user