Converting TIFF files to PDF and/or JPEG

S

sophie_newbie

Hey guys,

As part of a college project I'm trying to write a script to convert
TIFF images downloaded from the US patent office site, www.uspto.gov.

The tiff images are encoded using CCITT Group 4 compression and appear
to throw an error when i try to save them using the Image library:


It looks like this odd compression format is not supported, or am i
wrong?

I know its a long shot but would anyone have a different solution?

Sophie.
 
F

Fredrik Lundh

sophie_newbie said:
As part of a college project I'm trying to write a script to convert
TIFF images downloaded from the US patent office site, www.uspto.gov.

The tiff images are encoded using CCITT Group 4 compression and appear
to throw an error when i try to save them using the Image library:


It looks like this odd compression format is not supported, or am i
wrong?

I know its a long shot but would anyone have a different solution?

http://mail.python.org/pipermail/python-list/2005-January/258893.html

</F>
 
P

Paul Rubin

sophie_newbie said:
It looks like this odd compression format is not supported, or am i
wrong?

I know its a long shot but would anyone have a different solution?

I don't know about doing it directly in Python but there's a Linux
command line utility called tiff2ps (and now tiff2pdf) that I've done
that with.

At one point I was doing a lot of these conversions and I remember
writing a Python script around the command line utility to take care
of finding the files to convert, generating the right filenames, and
so forth. It was no big deal.
 
B

billuseslinux

The Tiff library and utilities combined with Ghostscript make this very
easy.

http://www.remotesensing.org/libtiff/

http://www.cs.wisc.edu/~ghost/

With the above two packages installed, you can do something like this
in Python:

def tiff2pdf(width, length, files):
path, filename = os.path.split(files)
name, ext = os.path.splitext(filename)
output = os.path.join(path, name + ".pdf")
command = \
'tiff2ps -a2 -w%s -h%s "%s" | ps2pdf - "%s"' % (width, length,
files, output)
os.popen(command)

I use a function like this all the time to convert Tiffs to PDF.

HTH

Bill
 
S

sophie_newbie

Hmm, does anyone know if there is a way to uncompress Tiff files in
python itself without having to make an os call.

This is because the script is kind of supposed to run on windows
also...

Sophie.
 

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,822
Latest member
israfaceZa

Latest Threads

Top