[Image-SIG] Re: TIF image with jpeg-compression error

Fredrik Lundh fredrik at pythonware.com
Mon Apr 26 05:10:34 EDT 2004


Ulrik Svensson wrote:

> PIL 1.1.4 (Debian package ver 1.1.4-3) does not seem to handle a
> tif-image with jpeg-compression, created with GIMP. The test image is
> attached.

I've attached a patch.

thanks /F

Index: PIL/TiffImagePlugin.py
===================================================================
--- PIL/TiffImagePlugin.py      (revision 1785)
+++ PIL/TiffImagePlugin.py      (working copy)
@@ -472,14 +472,19 @@
         args = None
         if rawmode == "RGB" and self._planar_configuration == 2:
             rawmode = rawmode[layer]
-        if self._compression == "raw":
+        compression = self._compression
+        if compression == "raw":
             args = (rawmode, 0, 1)
-        if self._compression in ["packbits", "tiff_lzw", "jpeg"]:
-            args = rawmode
-            if self._compression == "jpeg" and self.tag.has_key(JPEGTABLES):
+        elif compression == "jpeg":
+            args = rawmode, ""
+            if self.tag.has_key(JPEGTABLES):
                 # Hack to handle abbreviated JPEG headers
                 self.tile_prefix = self.tag[JPEGTABLES]
-            elif self._compression == "tiff_lzw" and self.tag.has_key(317):
+        elif compression == "packbits":
+            args = rawmode
+        elif compression == "tiff_lzw":
+            args = rawmode
+            if self.tag.has_key(317):
                 # Section 14: Differencing Predictor
                 self.decoderconfig = (self.tag[PREDICTOR][0],)






More information about the Image-SIG mailing list