[Image-SIG] Re: Tiff g3
Vladimir Pastukhov
vpastukhov at naumen.ru
Thu Dec 11 11:00:37 EST 2003
Hello,
ewc at axelero.hu wrote:
> Hello,
>
> I found, that the mentioned problem is because of RESOLUTION_UNIT tag.
> It looks like it has wrong number. Around line 635 in
...
> When I reqrite ifd[key] = 0x2, it is OK (I know, this is a very ugly
> hack).
You can try a better fix from the attached file.
> I wanted to save tiff files in G3 format, is it hard to build it into
> this patch? I mean using libtiff for this work also.
The work can take from 2 to 5 days depending on your
knowledge of PIL and libtiff internals, and C. I have
no plans for adding group3/4 encoding, at least until
our customers require it (not likely).
Best regards,
--
Vladimir Pastukhov <vpastukhov at naumen.ru>
NauDoc CMS/DMS Senior Developer
NAUMEN Company http://www.naumen.com
-------------- next part --------------
--- TiffImagePlugin.py.orig Tue Jul 29 20:00:25 2003
+++ TiffImagePlugin.py Thu Dec 11 20:34:08 2003
@@ -345,7 +345,7 @@
elif tag in (X_RESOLUTION, Y_RESOLUTION):
# identify rational data fields
typ = 5
- continue
+ value = reduce(lambda a,b: a+b, value)
else:
typ = 3
for v in value:
@@ -631,8 +631,10 @@
if hasattr(im, 'tag'):
# preserve tags from original TIFF image file
for key in (RESOLUTION_UNIT, X_RESOLUTION, Y_RESOLUTION):
- if im.tag.tagdata.has_key(key):
- ifd[key] = im.tag.tagdata.get(key)
+ try:
+ ifd[key] = im.tag[key]
+ except KeyError:
+ pass
if im.encoderinfo.has_key("description"):
ifd[IMAGEDESCRIPTION] = im.encoderinfo["description"]
if im.encoderinfo.has_key("resolution"):
More information about the Image-SIG
mailing list