mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-27 10:26:19 +03:00
Fixed default numresolution for small JPEG2000 images
This commit is contained in:
parent
85d009c697
commit
bd298b128c
|
@ -127,6 +127,16 @@ def test_prog_res_rt():
|
||||||
assert_image_equal(im, test_card)
|
assert_image_equal(im, test_card)
|
||||||
|
|
||||||
|
|
||||||
|
def test_default_num_resolutions():
|
||||||
|
for num_resolutions in range(2, 6):
|
||||||
|
d = 1 << (num_resolutions - 1)
|
||||||
|
im = test_card.resize((d - 1, d - 1))
|
||||||
|
with pytest.raises(OSError):
|
||||||
|
roundtrip(im, num_resolutions=num_resolutions)
|
||||||
|
reloaded = roundtrip(im)
|
||||||
|
assert_image_equal(im, reloaded)
|
||||||
|
|
||||||
|
|
||||||
def test_reduce():
|
def test_reduce():
|
||||||
with Image.open("Tests/images/test-card-lossless.jp2") as im:
|
with Image.open("Tests/images/test-card-lossless.jp2") as im:
|
||||||
assert callable(im.reduce)
|
assert callable(im.reduce)
|
||||||
|
|
|
@ -248,4 +248,4 @@ class TestPyDecoder:
|
||||||
def test_oserror(self):
|
def test_oserror(self):
|
||||||
im = Image.new("RGB", (1, 1))
|
im = Image.new("RGB", (1, 1))
|
||||||
with pytest.raises(OSError):
|
with pytest.raises(OSError):
|
||||||
im.save(BytesIO(), "JPEG2000")
|
im.save(BytesIO(), "JPEG2000", num_resolutions=2)
|
||||||
|
|
|
@ -458,6 +458,12 @@ j2k_encode_entry(Imaging im, ImagingCodecState state) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!context->num_resolutions) {
|
||||||
|
while (tile_width < (1 << (params.numresolution - 1U)) || tile_height < (1 << (params.numresolution - 1U))) {
|
||||||
|
params.numresolution -= 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (context->cinema_mode != OPJ_OFF) {
|
if (context->cinema_mode != OPJ_OFF) {
|
||||||
j2k_set_cinema_params(im, components, ¶ms);
|
j2k_set_cinema_params(im, components, ¶ms);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user