[Tutor] wx to convert Group 4 Tifs to Gifs

Albert-Jan Roskam fomcl at yahoo.com
Thu Aug 26 11:46:38 CEST 2010


Hi,

I have a small application, written in Tkinter. It is supposed to display a tif 
image, among other things. The problem is, PIL won't decode group 4 Tifs (G4 
TIF).
The tifs that I have are about 125kb and contain two pages per file. They're 
scanned, monochrome files. I need the second page of the tif, more specifically 
the lower half 

of the second page. I will have 5000-6000 tifs eventually, to manual conversion 
is not an option.

While googling around, I found many other people who faced the same problem. 
Since I cannot download executables here, I decided to use wx.
Ideally, I'd like an object that can be handled with Tkinter.PhotoImage, but I'm 
also very happy with a simple program that converts from G4 tif to Gif.
I have zero knowledge from wx. Therefroe, I'd really appreciate some pointers as 
to how to make the program below work.

import wx, os
def tif2gif(infile):
  """ This does *not* work """
  SECONDPAGE = 1
  outfile = os.path.splitext(infile[0] + ".gif")
  image   = wx.Image(name = infile, type = wx.BITMAP_TYPE_TIF, index = 
SECONDPAGE) 

  bitmap  = wx.BitmapFromImage(self.image)
  bitmap.SaveFile(outfile", wx.BITMAP_TYPE_GIF)
tif2gif(infile  = "d:/temp/somefile.tif")
 
Thank you very much in advance!
 
Cheers!!
Albert-Jan 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
All right, but apart from the sanitation, the medicine, education, wine, public 
order, irrigation, roads, a fresh water system, and public health, what have the 
Romans ever done for us?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 


      
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100826/136aa70c/attachment.html>


More information about the Tutor mailing list