mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-08-14 09:14:45 +03:00
Add tests for working with uint16 greyscale TIFFs.
This commit is contained in:
parent
d2a7de2c25
commit
d6c9ac175e
BIN
Tests/images/uint16_greyscale.tif
Normal file
BIN
Tests/images/uint16_greyscale.tif
Normal file
Binary file not shown.
|
@ -3,7 +3,7 @@ import logging
|
||||||
import struct
|
import struct
|
||||||
|
|
||||||
from helper import unittest, PillowTestCase, hopper, py3
|
from helper import unittest, PillowTestCase, hopper, py3
|
||||||
|
import numpy as np
|
||||||
from PIL import Image, TiffImagePlugin
|
from PIL import Image, TiffImagePlugin
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
@ -450,6 +450,28 @@ class TestFileTiff(PillowTestCase):
|
||||||
# Should not raise UnicodeDecodeError or anything else
|
# Should not raise UnicodeDecodeError or anything else
|
||||||
im.save(outfile)
|
im.save(outfile)
|
||||||
|
|
||||||
|
def test_save_greyscale_uint16_tiff(self):
|
||||||
|
'''
|
||||||
|
Save uint16 data as a greyscale uint16 TIFF.
|
||||||
|
'''
|
||||||
|
data = np.full([200, 200], 65535, np.uint16)
|
||||||
|
im = Image.fromarray(data)
|
||||||
|
outfile = self.tempfile("temp.tif")
|
||||||
|
im.save(outfile)
|
||||||
|
|
||||||
|
def test_roundtrip_greyscale_uint16_tiff(self):
|
||||||
|
'''
|
||||||
|
Confirm that all data saved to a uint16 TIFF is preserved.
|
||||||
|
Note: This will fail if test_save_greyscale_uint16_tiff() fails.
|
||||||
|
'''
|
||||||
|
data = np.full([200, 200], 65535, np.uint16)
|
||||||
|
im = Image.fromarray(data)
|
||||||
|
outfile = self.tempfile("temp.tif")
|
||||||
|
im.save(outfile)
|
||||||
|
|
||||||
|
out_im = Image.open(outfile)
|
||||||
|
self.assert_image_equal(im, out_im)
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user