Merge pull request #284 from wiredfool/g4_fillorder

G4 fillorder
This commit is contained in:
Alex Clark ☺ 2013-07-11 03:38:18 -07:00
commit f6766ad960
5 changed files with 388 additions and 361 deletions

View File

@ -782,6 +782,23 @@ class TiffImageFile(ImageFile.ImageFile):
# it doesn't use a file descriptor.
fp = False
# libtiff handles the fillmode for us, so 1;IR should
# actually be 1;I. Including the R double reverses the
# bits, so stripes of the image are reversed. See
# https://github.com/python-imaging/Pillow/issues/279
if fillorder == 2:
key = (
self.tag.prefix, photo, format, 1,
self.tag.get(BITSPERSAMPLE, (1,)),
self.tag.get(EXTRASAMPLES, ())
)
if Image.DEBUG:
print("format key:", key)
# this should always work, since all the
# fillorder==2 modes have a corresponding
# fillorder=1 mode
self.mode, rawmode = OPEN_INFO[key]
# Offset in the tile tuple is 0, we go from 0,0 to
# w,h, and we only do this once -- eds
a = (rawmode, self._compression, fp )

Binary file not shown.

After

Width:  |  Height:  |  Size: 989 B

Binary file not shown.

View File

@ -70,6 +70,14 @@ def test_g4_eq_png():
assert_image_equal(g4, png)
# see https://github.com/python-imaging/Pillow/issues/279
def test_g4_fillorder_eq_png():
""" Checking that we're actually getting the data that we expect"""
png = Image.open('Tests/images/g4-fillorder-test.png')
g4 = Image.open('Tests/images/g4-fillorder-test.tif')
assert_image_equal(g4, png)
def test_g4_write():
"""Checking to see that the saved image is the same as what we wrote"""
file = "Tests/images/lena_g4_500.tif"
@ -95,3 +103,5 @@ def test_adobe_deflate_tiff():
assert_equal(im.size, (278, 374))
assert_equal(im.tile[0][:3], ('tiff_adobe_deflate', (0, 0, 278, 374), 0))
assert_no_exception(lambda: im.load())

File diff suppressed because it is too large Load Diff