Skip to content

Commit

Permalink
Merge 7f7b534 into c7136f7
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Aug 26, 2017
2 parents c7136f7 + 7f7b534 commit 2fec3e5
Show file tree
Hide file tree
Showing 8 changed files with 588 additions and 157 deletions.
1 change: 1 addition & 0 deletions PIL/PyAccess.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ def set_pixel(self, x, y, color):
pixel.r = min(color[0], 255)
pixel.g = min(color[1], 255)
pixel.b = min(color[2], 255)
pixel.a = 255


class _PyAccess32_4(PyAccess):
Expand Down
18 changes: 17 additions & 1 deletion PIL/TiffImagePlugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,17 @@
(II, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10
(MM, 2, (1,), 1, (8, 8, 8, 8), (999,)): ("RGBA", "RGBA"), # Corel Draw 10

(II, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16L"),
(MM, 2, (1,), 1, (16, 16, 16), ()): ("RGB", "RGB;16B"),
(II, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16L"),
(MM, 2, (1,), 1, (16, 16, 16, 16), ()): ("RGBA", "RGBA;16B"),
(II, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16L"),
(MM, 2, (1,), 1, (16, 16, 16, 16), (0,)): ("RGBX", "RGBX;16B"),
(II, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16L"),
(MM, 2, (1,), 1, (16, 16, 16, 16), (1,)): ("RGBA", "RGBa;16B"),
(II, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16L"),
(MM, 2, (1,), 1, (16, 16, 16, 16), (2,)): ("RGBA", "RGBA;16B"),

(II, 3, (1,), 1, (1,), ()): ("P", "P;1"),
(MM, 3, (1,), 1, (1,), ()): ("P", "P;1"),
(II, 3, (1,), 2, (1,), ()): ("P", "P;1R"),
Expand Down Expand Up @@ -230,7 +241,12 @@
(MM, 8, (1,), 1, (8, 8, 8), ()): ("LAB", "LAB"),
}

PREFIXES = [b"MM\000\052", b"II\052\000", b"II\xBC\000"]
PREFIXES = [
b"MM\x00\x2A", # Valid TIFF header with big-endian byte order
b"II\x2A\x00", # Valid TIFF header with little-endian byte order
b"MM\x2A\x00", # Invalid TIFF header, assume big-endian
b"II\x00\x2A", # Invalid TIFF header, assume little-endian
]


def _accept(prefix):
Expand Down
Binary file added Tests/images/tiff_16bit_RGBa.tiff
Binary file not shown.
8 changes: 8 additions & 0 deletions Tests/test_file_tiff.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,14 @@ def test_mac_tiff(self):
self.assertEqual(im.tile, [('raw', (0, 0, 55, 43), 8, ('RGBa', 0, 1))])
im.load()

def test_16bit_RGBa_tiff(self):
im = Image.open("Tests/images/tiff_16bit_RGBa.tiff")

self.assertEqual(im.mode, "RGBA")
self.assertEqual(im.size, (100, 40))
self.assertEqual(im.tile, [('tiff_lzw', (0, 0, 100, 40), 50, 'RGBa;16B')])
im.load()

def test_gimp_tiff(self):
# Read TIFF JPEG images from GIMP [@PIL168]

Expand Down
Loading

0 comments on commit 2fec3e5

Please sign in to comment.