[PyQt] creating TIFF with CCITT FAX group 4 compression
david at boddie.org.uk
Wed Jul 16 23:06:32 BST 2008
On Wed Jul 16 04:46:02 BST 2008, Glenn Linderman wrote:
> So I generate a QImage with a B&W (bitonal) image, using PyQt.
> Writing it out produces a full-color 32bpp uncompressed TIFF file. Ick.
> QImage doesn't seem to know how to produce other variations. So I wrote it
> into a QByteArray per the docs, and extracted the data().
Apparently, you can write out LZW-compressed TIFFs:
> Found PIL, but PIL writes only uncompressed TIFF files too, according to
> its documentation.
There appears to be an attempt to patch it to support reading of group 4
And some code to use "tiffcp" to do the hard work of writing a compressed
> Found pytiff, can't figure out if it can write compressed TIFF files or
> not, nor how to make it read a TIFF from a string in memory, as it takes a
> filename, rather than a file() object as a parameter.
It looks like it might be able to perform the compression - see the FAQ on
Though it's certainly a problem that it uses file names rather than file
objects. I suppose it could be modified to support them.
> I'm pretty far down the list of Google hits, so thought maybe it was time
> to ask if anyone has figured out how to write out a QImage into a TIFF file
> along with using CCITT FAX group 4 compression.
This message from the python-list looks interesting:
Perhaps the FreeImagePy project mentioned will be useful:
Let us know if you find something that works.
More information about the PyQt