4

PIL doesn't natively support G4 images, is there some other python package that does? I need to read multi-page TIFF images and pull convert them into gif/png on the fly to serve up in a web page. (I'm not converting them all on the fly, but cherry picking them for display).

I've considered using ImageMagick which has that conversion ability, but I'd like to be able to reach into the TIFF files and see what is inside them for indexing.

boatcoder
  • 17,525
  • 18
  • 114
  • 178

2 Answers2

2

See this post about a patch against PIL, this project to wrap FreeImage, and this project to wrap libtiff.

agf
  • 171,228
  • 44
  • 289
  • 238
  • The PIL patch works and since I already have PIL loaded in my Django project, it seems to be the one to go with. – boatcoder Aug 14 '11 at 23:51
  • 1
    This was easy to fix in linux, but doing in windows (and in a VirtualENV to boot) nearly impossible to get working. I finally got all the compile issues solved, and have pushed the code to https://github.com/mark0978/PIL-withG4 feel free to use it. This will build/install on linux or on windows (and in virtualENVs). Hope it helps someone else. – boatcoder Aug 20 '11 at 04:24
  • 2
    You should let the PIL people know about that! – agf Aug 20 '11 at 08:34
  • I will, but this patch I used has been around since 2005, don't hold your breath. It uses some of the tiff private headers to work which would probably be a problem if tiff wasn't such an old format that the code fairly mature The libTiff code I used was from 2007 (3.8.2). I just looked and there is now a 4.0 that changes some of those files, but nothing that will affect this patch. – boatcoder Aug 20 '11 at 14:21
1

Using PythonMagick:

from PythonMagick import Image
Image('CCITT_4.TIF[0]').write("PNG8:CCITT_4.PNG")
cgohlke
  • 9,142
  • 2
  • 33
  • 36