Hi Markus, Thanks for your reply and sorry for the long delay.
Hey, in your travels, have you seen any fixes to allow the TIFF module to support writing with compression? It seems that the PIL always writes TIFF files uncompressed and doesn't seem to support writing with compression. I would love to find a fix for that, as well. Any help would be greatly appreciated. Thanks! Gary ----- Original Message ----- From: Markus Kemmerling To: Gary Bloom Cc: Image-SIG@python.org ; [EMAIL PROTECTED] Sent: Thursday, October 18, 2007 2:50 AM Subject: Re: [Image-SIG] BUG: PIL DPI trouble - fix for TIFF files (PIL 1.1.6) I would really like to see these fixes included in a next PIL release, if there will be one. (I also would like to see an egg release, but that's a different story.) Note, that I posted a similar fix (combining Florian's and your's) to the list a long time ago (july 2006). There is a small difference though, see below. Maybe a test for these fixes should be added, but I can't see any TIFF image tests at all in the PIL distribution. Am 10.10.2007 um 16:18 schrieb Gary Bloom: Here's a quick fix for the writing of the file, as well... Before making the fix below, go to line 721 and change the '1' to a '2' ! 721: ifd[RESOLUTION_UNIT] = 1 becomes 721: ifd[RESOLUTION_UNIT] = 2 Then make the changes listed below. This is consistent with those changes. This is a quick and dirty fix that I have not tested extensively, but it quickly allows me to read and write TIFF images with both the PIL and Photoshop, and each can see the DPI as set by the other. It fixes the problem I've had with PIL reading/writing TIFFs. Thanks, Florian! Regards, Gary Bloom Sales Engineer Sefas Innovation www.sefas.com ============ [Image-SIG] BUG: PIL DPI trouble - fix for TIFF files (PIL 1.1.6) Florian Höch lists+Image_SIG at hoech.org Fri Oct 5 00:05:16 CEST 2007 a.. Previous message: [Image-SIG] fromstring image question b.. Next message: [Image-SIG] Image transpose c.. Messages sorted by: [ date ] [ thread ] [ subject ] [ author ] ---------------------------------------------------------------------------- PIL only adds a dpi entry in the info dictionary if no resolution unit is specified in the TIFF file. This seems to be because of a misinterpretation of resolution unit values: they have a different meaning than in a JPEG file. JPEG: 0 = None; 1 = inches; 2 = cm. TIFF: 1 = None; 2 = inches; 3 = cm (see http://www.awaresystems.be/imaging/tiff/tifftags/resolutionunit.html and http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/JPEG.html) Here's a quick fix: Open TiffImagePlugin.py and go to line 577. Change the code: xres = getscalar(X_RESOLUTION, (1, 1)) yres = getscalar(Y_RESOLUTION, (1, 1)) if xres and yres: xres = xres[0] / (xres[1] or 1) yres = yres[0] / (yres[1] or 1) resunit = getscalar(RESOLUTION_UNIT, 1) if resunit == 2: # Inches self.info["dpi"] = xres, yres elif resunit == 3: # Centimeters self.info["dpi"] = xres * 2.54, yres * 2.54When converting from inches to centimeters, shouldn't you rather divide by 2.54 instead of multiplying? else: # No absolute unit of measurement. self.info["resolution"] = xres, yres Regards, Florian Hoech _______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig Regards, Markus Kemmerling
_______________________________________________ Image-SIG maillist - Image-SIG@python.org http://mail.python.org/mailman/listinfo/image-sig