Added I;16 PNG save

This commit is contained in:
Andrew Murray 2019-03-12 17:28:42 +11:00
parent 906917b748
commit ce9dd67540
3 changed files with 9 additions and 14 deletions

View File

@ -88,20 +88,13 @@ class TestFilePng(PillowTestCase):
self.assertEqual(im.format, "PNG")
self.assertEqual(im.get_format_mimetype(), 'image/png')
hopper("1").save(test_file)
Image.open(test_file)
hopper("L").save(test_file)
Image.open(test_file)
hopper("P").save(test_file)
Image.open(test_file)
hopper("RGB").save(test_file)
Image.open(test_file)
hopper("I").save(test_file)
Image.open(test_file)
for mode in ["1", "L", "P", "RGB", "I", "I;16"]:
im = hopper(mode)
im.save(test_file)
reloaded = Image.open(test_file)
if mode == "I;16":
reloaded = reloaded.convert(mode)
self.assert_image_equal(reloaded, im)
def test_invalid_file(self):
invalid_file = "Tests/images/flower.jpg"

View File

@ -707,6 +707,7 @@ _OUTMODES = {
"L": ("L", b'\x08\x00'),
"LA": ("LA", b'\x08\x04'),
"I": ("I;16B", b'\x10\x00'),
"I;16": ("I;16B", b'\x10\x00'),
"P;1": ("P;1", b'\x01\x03'),
"P;2": ("P;2", b'\x02\x03'),
"P;4": ("P;4", b'\x04\x03'),

View File

@ -639,6 +639,7 @@ static struct {
/* storage modes */
{"I;16", "I;16", 16, copy2},
{"I;16", "I;16B", 16, packI16N_I16B},
{"I;16B", "I;16B", 16, copy2},
{"I;16L", "I;16L", 16, copy2},
{"I;16", "I;16N", 16, packI16N_I16}, // LibTiff native->image endian.