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: http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qimagewriter.html#setCompression > 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 compressed files: http://mail.python.org/pipermail/image-sig/2003-July/002354.html And some code to use "tiffcp" to do the hard work of writing a compressed image: http://groups.google.co.uk/group/comp.lang.python/msg/0af79e0c99609f9d > 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 this page: http://www.haynold.com/software_projects/2004/pytiff/ 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: http://mail.python.org/pipermail/python-list/2006-September/405457.html Perhaps the FreeImagePy project mentioned will be useful: http://freeimagepy.sourceforge.net/ Let us know if you find something that works. Good luck! David _______________________________________________ PyQt mailing list [email protected] http://www.riverbankcomputing.com/mailman/listinfo/pyqt
