Discussion:
Tiff g3
e***@axelero.hu
2003-12-10 10:06:48 UTC
Permalink
Hello,

does anybody have TIFF G3 compression implemented for PIL?

Thanks in advance,
Thomas



_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
Fredrik Lundh
2003-12-11 09:47:38 UTC
Permalink
Post by e***@axelero.hu
does anybody have TIFF G3 compression implemented for PIL?
this might be helpful:

http://mail.python.org/pipermail/image-sig/2003-July/002354.html

</F>




_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
e***@axelero.hu
2003-12-11 10:58:50 UTC
Permalink
Hello Fredrik,

many thanks!
Does anybody know when will be a new PIL available including this
patch?

I applied a patch. I was able to open TIFF G3 files but got this when
I tryed to save:
Traceback (most recent call last):
File "./tiff.py", line 36, in ?
im.save("/tmp/test_o.tiff")
File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1136, in save
SAVE[string.upper(format)](self, fp, filename)
File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 684, in _save
offset = ifd.save(fp)
File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 357, in save
data = string.join(map(o32, value), "")
File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 55, in ol32
return chr(i&255) + chr(i>>8&255) + chr(i>>16&255) + chr(i>>24&255)
TypeError: unsupported operand type(s) for &: 'str' and 'int'

Does anybody know what's wrong?

Thanks,
Thomas
Post by e***@axelero.hu
does anybody have TIFF G3 compression implemented for PIL?
FL> this might be helpful:

FL> http://mail.python.org/pipermail/image-sig/2003-July/002354.html

FL> </F>



_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
e***@axelero.hu
2003-12-11 12:41:25 UTC
Permalink
Hello,

I found, that the mentioned problem is because of RESOLUTION_UNIT tag.
It looks like it has wrong number. Around line 635 in
TiffImagePlugin.py:
# additions written by Greg Couch, ***@cgl.ucsf.edu
# inspired by image-sig posting from Kevin Cazabon, ***@home.com
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)
here, ifd[key] gets vaule: (3, '\x02\x00') and ol32 doesn't like this.
When I reqrite ifd[key] = 0x2, it is OK (I know, this is a very ugly
hack).

Other:
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.

Thanks in advance,
Thomas

Thursday, December 11, 2003, 11:58:50 AM, you wrote:

eah> Hello Fredrik,

eah> many thanks!
eah> Does anybody know when will be a new PIL available including this
eah> patch?

eah> I applied a patch. I was able to open TIFF G3 files but got this when
eah> I tryed to save:
eah> Traceback (most recent call last):
eah> File "./tiff.py", line 36, in ?
eah> im.save("/tmp/test_o.tiff")
eah> File "/usr/local/lib/python2.3/site-packages/PIL/Image.py", line 1136, in save
eah> SAVE[string.upper(format)](self, fp, filename)
eah> File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 684, in _save
eah> offset = ifd.save(fp)
eah> File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 357, in save
eah> data = string.join(map(o32, value), "")
eah> File "/usr/local/lib/python2.3/site-packages/PIL/TiffImagePlugin.py", line 55, in ol32
eah> return chr(i&255) + chr(i>>8&255) + chr(i>>16&255) + chr(i>>24&255)
eah> TypeError: unsupported operand type(s) for &: 'str' and 'int'

eah> Does anybody know what's wrong?

eah> Thanks,
eah> Thomas
Post by e***@axelero.hu
does anybody have TIFF G3 compression implemented for PIL?
FL>> this might be helpful:

FL>> http://mail.python.org/pipermail/image-sig/2003-July/002354.html

FL>> </F>



_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig
Vladimir Pastukhov
2003-12-11 16:00:37 UTC
Permalink
Hello,
Post by e***@axelero.hu
Hello,
I found, that the mentioned problem is because of RESOLUTION_UNIT tag.
It looks like it has wrong number. Around line 635 in
...
Post by e***@axelero.hu
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.
Post by e***@axelero.hu
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 <***@naumen.ru>
NauDoc CMS/DMS Senior Developer
NAUMEN Company http://www.naumen.com
e***@axelero.hu
2003-12-11 16:52:55 UTC
Permalink
Hello Vladimir,

thank you for your fast response, fast bugfix.

Regards,
Thomas

Thursday, December 11, 2003, 5:00:37 PM, you wrote:

VP> Hello,
Post by e***@axelero.hu
Hello,
I found, that the mentioned problem is because of RESOLUTION_UNIT tag.
It looks like it has wrong number. Around line 635 in
VP> ...
Post by e***@axelero.hu
When I reqrite ifd[key] = 0x2, it is OK (I know, this is a very ugly
hack).
VP> You can try a better fix from the attached file.
Post by e***@axelero.hu
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.
VP> The work can take from 2 to 5 days depending on your
VP> knowledge of PIL and libtiff internals, and C. I have
VP> no plans for adding group3/4 encoding, at least until
VP> our customers require it (not likely).

VP> Best regards,
VP>
VP>--
VP>Vladimir Pastukhov <***@naumen.ru>
VP>NauDoc CMS/DMS Senior Developer
VP>NAUMEN Company http://www.naumen.com



_______________________________________________
Image-SIG maillist - Image-***@python.org
http://mail.python.org/mailman/listinfo/image-sig

Loading...