Uncompressing TIFF files directly in Python

S

sophie_newbie

Hey guys,

OK this is a long shot but does anyone know of a way to uncompress tiff
files directly in python. I know it can be done with an os call but
that'll only work on unix and only if the right software is installed!

I need to convert tiff images downloaded from uspto.gov to pdf, these
images are compressed using G4, so I dunno if anyone knows of a method
of doing this witout the os call! Surely there is a utility out there
somewhere?

Sophie
 
P

Peter Hansen

sophie_newbie said:
Hey guys,

OK this is a long shot but does anyone know of a way to uncompress tiff
files directly in python. I know it can be done with an os call but
that'll only work on unix and only if the right software is installed!

I need to convert tiff images downloaded from uspto.gov to pdf, these
images are compressed using G4, so I dunno if anyone knows of a method
of doing this witout the os call! Surely there is a utility out there
somewhere?

Why didn't you want an OS call? Do you have other constraints that
would invalidate anything but a pure Python solution?

What about using FreeImage? (http://freeimage.sourceforge.net)

It can be called via ctypes as http://freeimagepy.sourceforge.net/ does.

-Peter
 
P

Paul Rubin

sophie_newbie said:
I need to convert tiff images downloaded from uspto.gov to pdf, these
images are compressed using G4, so I dunno if anyone knows of a method
of doing this witout the os call! Surely there is a utility out there
somewhere?

There's a libtiff library callable from C. Maybe someone has written
Python wrappers for it; if not, maybe you can become that someone.
 
S

sophie_newbie

I mainly just need it to work with windows and assumed that an os call
would only work with windows!

I've downloaded that free image software and the ctypes program, it
seems to be working but I haven't yet worked out how to get it to
decompress a G4 TIFF image...

If anyone knows it would be of help?
 
F

Fredrik Lundh

sophie_newbie said:
I mainly just need it to work with windows and assumed that an os call
would only work with windows!

I've downloaded that free image software and the ctypes program, it
seems to be working but I haven't yet worked out how to get it to
decompress a G4 TIFF image...

If anyone knows it would be of help?

tiffcp and friends are available for windows too:

http://gnuwin32.sourceforge.net/packages/tiff.htm

infile = "somefile.tif"

os.system("tiffcp -c none %s temp.tif" % infile)

im = Image.open("temp.tif")

</F>
 
P

Peter Hansen

sophie_newbie said:
I mainly just need it to work with windows and assumed that an os call
would only work with windows!

Presumably you mistyped something there, since what you are basically
saying is that an os call which only works on windows would suit you
just fine since you only care about windows.

-Peter
 
G

Gary Duzan

sophie_newbie said:
Hey guys,

OK this is a long shot but does anyone know of a way to uncompress tiff
files directly in python. I know it can be done with an os call but
that'll only work on unix and only if the right software is installed!

I need to convert tiff images downloaded from uspto.gov to pdf, these
images are compressed using G4, so I dunno if anyone knows of a method
of doing this witout the os call! Surely there is a utility out there
somewhere?

You can look into using the Python Imaging Library, which supports
reading TIFFs and runs on multiple platforms, including Windows.

http://www.pythonware.com/products/pil/

Gary Duzan
Motorola CHS
 
S

sophie_newbie

Ya that was the original plan but it didn't support the G4 compression
of the tif files!

I think the idea of using tiffcp is the best as it runs on both unix
and windows which is what i need!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top