mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-25 17:36:18 +03:00
Tests for endian issues in decoding 16bit tif images
This commit is contained in:
parent
366f9a5f35
commit
1945fecdb6
BIN
Tests/images/12bit.MM.cropped.tif
Normal file
BIN
Tests/images/12bit.MM.cropped.tif
Normal file
Binary file not shown.
BIN
Tests/images/12bit.MM.deflate.tif
Normal file
BIN
Tests/images/12bit.MM.deflate.tif
Normal file
Binary file not shown.
BIN
Tests/images/12bit.deflate.tif
Normal file
BIN
Tests/images/12bit.deflate.tif
Normal file
Binary file not shown.
|
@ -105,3 +105,25 @@ def test_adobe_deflate_tiff():
|
|||
assert_no_exception(lambda: im.load())
|
||||
|
||||
|
||||
def test_little_endian():
|
||||
im = Image.open('Tests/images/12bit.deflate.tif')
|
||||
assert_equal(im.getpixel((0,0)), 480)
|
||||
assert_equal(im.mode, 'I;16')
|
||||
|
||||
b = im.tobytes()
|
||||
# Bytes are in image native order (little endian)
|
||||
assert_equal(b[0], b'\xe0')
|
||||
assert_equal(b[1], b'\x01')
|
||||
|
||||
def test_big_endian():
|
||||
im = Image.open('Tests/images/12bit.MM.deflate.tif')
|
||||
|
||||
assert_equal(im.getpixel((0,0)), 480)
|
||||
assert_equal(im.mode, 'I;16B')
|
||||
|
||||
b = im.tobytes()
|
||||
|
||||
# Bytes are in image native order (big endian)
|
||||
assert_equal(b[0], b'\x01')
|
||||
assert_equal(b[1], b'\xe0')
|
||||
|
||||
|
|
|
@ -71,3 +71,28 @@ def test_xyres_tiff():
|
|||
im.tag.tags[Y_RESOLUTION] = (72,)
|
||||
im._setup()
|
||||
assert_equal(im.info['dpi'], (72., 72.))
|
||||
|
||||
|
||||
def test_little_endian():
|
||||
im = Image.open('Tests/images/12bit.cropped.tif')
|
||||
assert_equal(im.getpixel((0,0)), 480)
|
||||
assert_equal(im.mode, 'I;16')
|
||||
|
||||
b = im.tobytes()
|
||||
# Bytes are in image native order (little endian)
|
||||
assert_equal(b[0], b'\xe0')
|
||||
assert_equal(b[1], b'\x01')
|
||||
|
||||
def test_big_endian():
|
||||
im = Image.open('Tests/images/12bit.MM.cropped.tif')
|
||||
assert_equal(im.getpixel((0,0)), 480)
|
||||
assert_equal(im.mode, 'I;16B')
|
||||
|
||||
b = im.tobytes()
|
||||
|
||||
# Bytes are in image native order (big endian)
|
||||
assert_equal(b[0], b'\x01')
|
||||
assert_equal(b[1], b'\xe0')
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user