diff options
author | Sebastien Fabbro <bicatali@gentoo.org> | 2009-07-15 17:03:33 +0000 |
---|---|---|
committer | Sebastien Fabbro <bicatali@gentoo.org> | 2009-07-15 17:03:33 +0000 |
commit | e89ec0e2d6d6baeda1c98167f01c113537f5ffc5 (patch) | |
tree | e2b0616e2aa77b3250f540be3c40abb3ebc7398d /dev-python/imaging | |
parent | Remove sweep to avoid conflict with media-libs/sweep. #245439. (diff) | |
download | gentoo-2-e89ec0e2d6d6baeda1c98167f01c113537f5ffc5.tar.gz gentoo-2-e89ec0e2d6d6baeda1c98167f01c113537f5ffc5.tar.bz2 gentoo-2-e89ec0e2d6d6baeda1c98167f01c113537f5ffc5.zip |
Fixed tiff patch for proper tiff handling also with higher resolution (from Debian). Closing bug #277208
(Portage version: 2.2_rc33/cvs/Linux x86_64)
Diffstat (limited to 'dev-python/imaging')
-rw-r--r-- | dev-python/imaging/ChangeLog | 7 | ||||
-rw-r--r-- | dev-python/imaging/files/imaging-1.1.6-tiffendian.patch | 266 |
2 files changed, 45 insertions, 228 deletions
diff --git a/dev-python/imaging/ChangeLog b/dev-python/imaging/ChangeLog index fe9f8ab2e986..ccc3475d5c97 100644 --- a/dev-python/imaging/ChangeLog +++ b/dev-python/imaging/ChangeLog @@ -1,6 +1,11 @@ # ChangeLog for dev-python/imaging # Copyright 1999-2009 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/dev-python/imaging/ChangeLog,v 1.41 2009/07/03 09:57:58 idl0r Exp $ +# $Header: /var/cvsroot/gentoo-x86/dev-python/imaging/ChangeLog,v 1.42 2009/07/15 17:03:32 bicatali Exp $ + + 15 Jul 2009; Sébastien Fabbro <bicatali@gentoo.org> + files/imaging-1.1.6-tiffendian.patch: + Fixed tiff patch for proper tiff handling also with higher resolution + (from Debian). Closing bug #277208 03 Jul 2009; Christian Ruppert <idl0r@gentoo.org> imaging-1.1.6-r1.ebuild, +files/imaging-1.1.6-missing-math.patch: diff --git a/dev-python/imaging/files/imaging-1.1.6-tiffendian.patch b/dev-python/imaging/files/imaging-1.1.6-tiffendian.patch index df45d6b6c08b..441725a7fe12 100644 --- a/dev-python/imaging/files/imaging-1.1.6-tiffendian.patch +++ b/dev-python/imaging/files/imaging-1.1.6-tiffendian.patch @@ -1,228 +1,40 @@ ---- PIL/TiffImagePlugin.py.orig 2009-03-14 17:45:57.971128978 +0000 -+++ PIL/TiffImagePlugin.py 2009-03-14 17:46:22.789196585 +0000 -@@ -65,8 +65,9 @@ - return ord(c[o]) + (ord(c[o+1])<<8) - def il32(c,o=0): - return ord(c[o]) + (ord(c[o+1])<<8) + (ord(c[o+2])<<16) + (ord(c[o+3])<<24) -+ - def ol16(i): -- return chr(i&255) + chr(i>>8&255) -+ return chr(i>>8&255) + chr(i&255) - def ol32(i): - return chr(i&255) + chr(i>>8&255) + chr(i>>16&255) + chr(i>>24&255) +--- Imaging-1.1.6/PIL/Image.py.orig 2009-07-15 07:44:06.210499375 -0700 ++++ Imaging-1.1.6/PIL/Image.py 2009-07-15 07:47:38.546498713 -0700 +@@ -197,6 +197,7 @@ + "1": ('|b1', None), + "L": ('|u1', None), + "I": ('%si4' % _ENDIAN, None), # FIXME: is this correct? ++ "I;16": ('%si2' % _ENDIAN, None), + "F": ('%sf4' % _ENDIAN, None), # FIXME: is this correct? + "P": ('|u1', None), + "RGB": ('|u1', 3), +--- Imaging-1.1.6/PIL/TiffImagePlugin.py.orig 2009-07-15 07:50:27.723535040 -0700 ++++ Imaging-1.1.6/PIL/TiffImagePlugin.py 2009-07-15 07:50:40.490496978 -0700 +@@ -577,10 +577,16 @@ + xdpi = getscalar(X_RESOLUTION, (1, 1)) + ydpi = getscalar(Y_RESOLUTION, (1, 1)) + +- if xdpi and ydpi and getscalar(RESOLUTION_UNIT, 1) == 1: ++ if xdpi and ydpi: + xdpi = xdpi[0] / (xdpi[1] or 1) + ydpi = ydpi[0] / (ydpi[1] or 1) +- self.info["dpi"] = xdpi, ydpi ++ unit = getscalar(RESOLUTION_UNIT, 1) ++ if unit == 1: ++ self.info["aspect"] = xdpi, ydpi ++ elif unit == 2: ++ self.info["dpi"] = xdpi, ydpi ++ elif unit == 3: ++ self.info["dpi"] = (xdpi*.39370079, ydpi*.39370079) + + # build tile descriptors + x = y = l = 0 +@@ -718,7 +724,7 @@ + + dpi = im.encoderinfo.get("dpi") + if dpi: +- ifd[RESOLUTION_UNIT] = 1 ++ ifd[RESOLUTION_UNIT] = 2 + ifd[X_RESOLUTION] = _cvt_res(dpi[0]) + ifd[Y_RESOLUTION] = _cvt_res(dpi[1]) -@@ -75,6 +76,11 @@ - def ib32(c,o=0): - return ord(c[o+3]) + (ord(c[o+2])<<8) + (ord(c[o+1])<<16) + (ord(c[o])<<24) - -+def ob16(i): -+ return chr(i>>8&255) + chr(i&255) -+def ob32(i): -+ return chr(i>>24&255) + chr(i>>16&255) + chr(i>>8&255) + chr(i&255) -+ - # a few tag names, just to make the code below a bit more readable - IMAGEWIDTH = 256 - IMAGELENGTH = 257 -@@ -117,42 +123,76 @@ - } - - OPEN_INFO = { -- # (PhotoInterpretation, SampleFormat, FillOrder, BitsPerSample, -+ # (ByteOrder, PhotoInterpretation, SampleFormat, FillOrder, BitsPerSample, - # ExtraSamples) => mode, rawmode -- (0, 1, 1, (1,), ()): ("1", "1;I"), -- (0, 1, 2, (1,), ()): ("1", "1;IR"), -- (0, 1, 1, (8,), ()): ("L", "L;I"), -- (0, 1, 2, (8,), ()): ("L", "L;IR"), -- (1, 1, 1, (1,), ()): ("1", "1"), -- (1, 1, 2, (1,), ()): ("1", "1;R"), -- (1, 1, 1, (8,), ()): ("L", "L"), -- (1, 1, 1, (8,8), (2,)): ("LA", "LA"), -- (1, 1, 2, (8,), ()): ("L", "L;R"), -- (1, 1, 1, (16,), ()): ("I;16", "I;16"), -- (1, 2, 1, (16,), ()): ("I;16S", "I;16S"), -- (1, 2, 1, (32,), ()): ("I", "I;32S"), -- (1, 3, 1, (32,), ()): ("F", "F;32F"), -- (2, 1, 1, (8,8,8), ()): ("RGB", "RGB"), -- (2, 1, 2, (8,8,8), ()): ("RGB", "RGB;R"), -- (2, 1, 1, (8,8,8,8), (0,)): ("RGBX", "RGBX"), -- (2, 1, 1, (8,8,8,8), (1,)): ("RGBA", "RGBa"), -- (2, 1, 1, (8,8,8,8), (2,)): ("RGBA", "RGBA"), -- (2, 1, 1, (8,8,8,8), (999,)): ("RGBA", "RGBA"), # corel draw 10 -- (3, 1, 1, (1,), ()): ("P", "P;1"), -- (3, 1, 2, (1,), ()): ("P", "P;1R"), -- (3, 1, 1, (2,), ()): ("P", "P;2"), -- (3, 1, 2, (2,), ()): ("P", "P;2R"), -- (3, 1, 1, (4,), ()): ("P", "P;4"), -- (3, 1, 2, (4,), ()): ("P", "P;4R"), -- (3, 1, 1, (8,), ()): ("P", "P"), -- (3, 1, 1, (8,8), (2,)): ("PA", "PA"), -- (3, 1, 2, (8,), ()): ("P", "P;R"), -- (5, 1, 1, (8,8,8,8), ()): ("CMYK", "CMYK"), -- (6, 1, 1, (8,8,8), ()): ("YCbCr", "YCbCr"), -- (8, 1, 1, (8,8,8), ()): ("LAB", "LAB"), -+ ('l', 0, 1, 1, (1,), ()): ("1", "1;I"), -+ ('l', 0, 1, 2, (1,), ()): ("1", "1;IR"), -+ ('l', 0, 1, 1, (8,), ()): ("L", "L;I"), -+ ('l', 0, 1, 2, (8,), ()): ("L", "L;IR"), -+ ('l', 1, 1, 1, (1,), ()): ("1", "1"), -+ ('l', 1, 1, 2, (1,), ()): ("1", "1;R"), -+ ('l', 1, 1, 1, (8,), ()): ("L", "L"), -+ ('l', 1, 1, 1, (8,8), (2,)): ("LA", "LA"), -+ ('l', 1, 1, 2, (8,), ()): ("L", "L;R"), -+ ('l', 1, 1, 1, (16,), ()): ("I;16", "I;16"), -+ ('l', 1, 2, 1, (16,), ()): ("I;16S", "I;16S"), -+ ('l', 1, 2, 1, (32,), ()): ("I", "I;32S"), -+ ('l', 1, 3, 1, (32,), ()): ("F", "F;32F"), -+ ('l', 2, 1, 1, (8,8,8), ()): ("RGB", "RGB"), -+ ('l', 2, 1, 2, (8,8,8), ()): ("RGB", "RGB;R"), -+ ('l', 2, 1, 1, (8,8,8,8), (0,)): ("RGBX", "RGBX"), -+ ('l', 2, 1, 1, (8,8,8,8), (1,)): ("RGBA", "RGBa"), -+ ('l', 2, 1, 1, (8,8,8,8), (2,)): ("RGBA", "RGBA"), -+ ('l', 2, 1, 1, (8,8,8,8), (999,)): ("RGBA", "RGBA"), # corel draw 10 -+ ('l', 3, 1, 1, (1,), ()): ("P", "P;1"), -+ ('l', 3, 1, 2, (1,), ()): ("P", "P;1R"), -+ ('l', 3, 1, 1, (2,), ()): ("P", "P;2"), -+ ('l', 3, 1, 2, (2,), ()): ("P", "P;2R"), -+ ('l', 3, 1, 1, (4,), ()): ("P", "P;4"), -+ ('l', 3, 1, 2, (4,), ()): ("P", "P;4R"), -+ ('l', 3, 1, 1, (8,), ()): ("P", "P"), -+ ('l', 3, 1, 1, (8,8), (2,)): ("PA", "PA"), -+ ('l', 3, 1, 2, (8,), ()): ("P", "P;R"), -+ ('l', 5, 1, 1, (8,8,8,8), ()): ("CMYK", "CMYK"), -+ ('l', 6, 1, 1, (8,8,8), ()): ("YCbCr", "YCbCr"), -+ ('l', 8, 1, 1, (8,8,8), ()): ("LAB", "LAB"), -+ -+ ('b', 0, 1, 1, (1,), ()): ("1", "1;I"), -+ ('b', 0, 1, 2, (1,), ()): ("1", "1;IR"), -+ ('b', 0, 1, 1, (8,), ()): ("L", "L;I"), -+ ('b', 0, 1, 2, (8,), ()): ("L", "L;IR"), -+ ('b', 1, 1, 1, (1,), ()): ("1", "1"), -+ ('b', 1, 1, 2, (1,), ()): ("1", "1;R"), -+ ('b', 1, 1, 1, (8,), ()): ("L", "L"), -+ ('b', 1, 1, 1, (8,8), (2,)): ("LA", "LA"), -+ ('b', 1, 1, 2, (8,), ()): ("L", "L;R"), -+ ('b', 1, 1, 1, (16,), ()): ("I;16B", "I;16B"), -+ ('b', 1, 2, 1, (16,), ()): ("I;16BS", "I;16BS"), -+ ('b', 1, 2, 1, (32,), ()): ("I;32BS", "I;32BS"), -+ ('b', 1, 3, 1, (32,), ()): ("F;32BF", "F;32BF"), -+ ('b', 2, 1, 1, (8,8,8), ()): ("RGB", "RGB"), -+ ('b', 2, 1, 2, (8,8,8), ()): ("RGB", "RGB;R"), -+ ('b', 2, 1, 1, (8,8,8,8), (0,)): ("RGBX", "RGBX"), -+ ('b', 2, 1, 1, (8,8,8,8), (1,)): ("RGBA", "RGBa"), -+ ('b', 2, 1, 1, (8,8,8,8), (2,)): ("RGBA", "RGBA"), -+ ('b', 2, 1, 1, (8,8,8,8), (999,)): ("RGBA", "RGBA"), # corel draw 10 -+ ('b', 3, 1, 1, (1,), ()): ("P", "P;1"), -+ ('b', 3, 1, 2, (1,), ()): ("P", "P;1R"), -+ ('b', 3, 1, 1, (2,), ()): ("P", "P;2"), -+ ('b', 3, 1, 2, (2,), ()): ("P", "P;2R"), -+ ('b', 3, 1, 1, (4,), ()): ("P", "P;4"), -+ ('b', 3, 1, 2, (4,), ()): ("P", "P;4R"), -+ ('b', 3, 1, 1, (8,), ()): ("P", "P"), -+ ('b', 3, 1, 1, (8,8), (2,)): ("PA", "PA"), -+ ('b', 3, 1, 2, (8,), ()): ("P", "P;R"), -+ ('b', 5, 1, 1, (8,8,8,8), ()): ("CMYK", "CMYK"), -+ ('b', 6, 1, 1, (8,8,8), ()): ("YCbCr", "YCbCr"), -+ ('b', 8, 1, 1, (8,8,8), ()): ("LAB", "LAB"), - } - - PREFIXES = ["MM\000\052", "II\052\000", "II\xBC\000"] -+PREFIX_TO_BYTEORDER = {"MM":"b", "II":"l"} -+BYTEORDER_TO_PREFIX = {"b":"MM", "l":"II"} - - def _accept(prefix): - return prefix[:4] in PREFIXES -@@ -165,16 +205,19 @@ - # represents a TIFF tag directory. to speed things up, - # we don't decode tags unless they're asked for. - -- def __init__(self, prefix="II"): -+ def __init__(self, prefix): - self.prefix = prefix[:2] - if self.prefix == "MM": - self.i16, self.i32 = ib16, ib32 -- # FIXME: save doesn't yet support big-endian mode... -+ self.o16, self.o32 = ob16, ob32 -+ - elif self.prefix == "II": - self.i16, self.i32 = il16, il32 - self.o16, self.o32 = ol16, ol32 - else: - raise SyntaxError("not a TIFF IFD") -+ self.byteorder = PREFIX_TO_BYTEORDER[self.prefix] -+ - self.reset() - - def reset(self): -@@ -555,7 +598,7 @@ - - # mode: check photometric interpretation and bits per pixel - key = ( -- photo, format, fillorder, -+ self.tag.byteorder, photo, format, fillorder, - self.tag.get(BITSPERSAMPLE, (1,)), - self.tag.get(EXTRASAMPLES, ()) - ) -@@ -636,26 +679,31 @@ - # - # -------------------------------------------------------------------- - # Write TIFF files -- -+# little endian is default except for image modes with explict big endian byte-order - # little endian is default - - SAVE_INFO = { -- # mode => rawmode, photometrics, sampleformat, bitspersample, extra -- "1": ("1", 1, 1, (1,), None), -- "L": ("L", 1, 1, (8,), None), -- "LA": ("LA", 1, 1, (8,8), 2), -- "P": ("P", 3, 1, (8,), None), -- "PA": ("PA", 3, 1, (8,8), 2), -- "I": ("I;32S", 1, 2, (32,), None), -- "I;16": ("I;16", 1, 1, (16,), None), -- "I;16S": ("I;16S", 1, 2, (16,), None), -- "F": ("F;32F", 1, 3, (32,), None), -- "RGB": ("RGB", 2, 1, (8,8,8), None), -- "RGBX": ("RGBX", 2, 1, (8,8,8,8), 0), -- "RGBA": ("RGBA", 2, 1, (8,8,8,8), 2), -- "CMYK": ("CMYK", 5, 1, (8,8,8,8), None), -- "YCbCr": ("YCbCr", 6, 1, (8,8,8), None), -- "LAB": ("LAB", 8, 1, (8,8,8), None), -+ # mode => rawmode, byteorder, photometrics, sampleformat, bitspersample, extra -+ "1": ("1", 'l', 1, 1, (1,), None), -+ "L": ("L", 'l', 1, 1, (8,), None), -+ "LA": ("LA", 'l', 1, 1, (8,8), 2), -+ "P": ("P", 'l', 3, 1, (8,), None), -+ "PA": ("PA", 'l', 3, 1, (8,8), 2), -+ "I": ("I;32S", 'l', 1, 2, (32,), None), -+ "I;16": ("I;16", 'l', 1, 1, (16,), None), -+ "I;16S": ("I;16S", 'l', 1, 2, (16,), None), -+ "F": ("F;32F", 'l', 1, 3, (32,), None), -+ "RGB": ("RGB", 'l', 2, 1, (8,8,8), None), -+ "RGBX": ("RGBX", 'l', 2, 1, (8,8,8,8), 0), -+ "RGBA": ("RGBA", 'l', 2, 1, (8,8,8,8), 2), -+ "CMYK": ("CMYK", 'l', 5, 1, (8,8,8,8), None), -+ "YCbCr": ("YCbCr", 'l', 6, 1, (8,8,8), None), -+ "LAB": ("LAB", 'l', 8, 1, (8,8,8), None), -+ -+ "I;32BS": ("I;32BS", 'b', 1, 2, (32,), None), -+ "I;16B": ("I;16B", 'b', 1, 1, (16,), None), -+ "I;16BS": ("I;16BS", 'b', 1, 2, (16,), None), -+ "F;32BF": ("F;32BF", 'b', 1, 3, (32,), None), - } - - def _cvt_res(value): -@@ -671,11 +719,11 @@ - def _save(im, fp, filename): - - try: -- rawmode, photo, format, bits, extra = SAVE_INFO[im.mode] -+ rawmode, byteorder, photo, format, bits, extra = SAVE_INFO[im.mode] - except KeyError: - raise IOError, "cannot write mode %s as TIFF" % im.mode - -- ifd = ImageFileDirectory() -+ ifd = ImageFileDirectory(BYTEORDER_TO_PREFIX[byteorder]) - - # tiff header (write via IFD to get everything right) - fp.write(ifd.prefix + ifd.o16(42) + ifd.o32(8)) |