On 26/08/2010 11:46, Albert-Jan Roskam wrote:
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?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Any chance you run Linux ?  If so you can do it with convert like

for fn in ./*.tif; do convert $fn $fn.jpg; done
for fn in ./*-1.jpg; do convert $fn $fn.gif; done

The reason for the 2 step conversion is tif -> gif seems to only give you access to the first page.

--
Kind Regards,
Christian Witts


_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to