[PyQt] creating TIFF with CCITT FAX group 4 compression

Glenn Linderman v+pyqt at g.nevcal.com
Thu Jul 17 21:29:30 BST 2008


Hi David,

Thanks for the response.


On approximately 7/16/2008 3:06 PM, came the following characters from the keyboard of David Boddie:
> Apparently, you can write out LZW-compressed TIFFs:
>
> http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qimagewriter.html#setCompression
>   

That'd be better than nothing, but still in color, so still much huger than necessary.  I totally missed this.  Being a Python newbie is tough, after getting to be pretty experienced with Perl.

The ImageMagick people say they support PerlMagick, but that PythonMagick was user-contributed, and they don't support it -- apparently, neither does the original contributor, as far as I can tell from timestamps on things...

>> 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
>   

Reading isn't the goal.  Generating/creating is the goal.  I had found this, too.

> 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
>   

This is interesting for platforms that have an available tiffcp.  Unfortunately, I can only find tiffcp for a _subset_ of Linux distributions (could probably be compiled for the others), for Windows, and not at all for Mac -- the tiffutil package available there is derived from tiffcp, but seems to sidestep support for G4 compression.  Maybe tiffcp could be compiled for Mac, uncertain.


>> 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.
>   

Hmm.  In 2004 or 2005 Oliver M. Haynold talks about a "next release" containing "toString" and "fromString", which would likely work-around the file names issue.  With the FAQ (I had found pytiff, but not the FAQ), it looks like the compression is possible.  But the remaining problem is "fromString".  And the dates... it is 2008 now, why can't we find pytiff 0.2?  And where is Oliver M. Haynold?  Likely on to other things... yep, graduated 2005, busy with a real job, maybe even a life.  Inquiry will be sent.  This looks promising, if it can be tweaked to accept input from strings in addition to files.

Hmm.  Tried to install it, needs M$ VC 7.1 (that is what Python 2.5 was compiled with, I guess), I have VC 6.0 and VC 8.0 installed...  Aargh!  Not another version of VC to have to be installed :(   So this experiment will have to be deferred a bit.  I wonder which would be easier -- to install VC 7.1, or recompile Python, PyQt, and the other extensions, with VC 8.0...


>> 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
>   

Decoding only, it seems.  Had seen this.

> Perhaps the FreeImagePy project mentioned will be useful:
>
> http://freeimagepy.sourceforge.net/
>   

Sounds useful, my other message responding to the other person that pointed this one out mentions out that it is pretty daunting for a Python newbie an Qt newbie to think about compiling this on 3 different platforms...  maybe in 6 months it will seem simpler.  And see compiler woes above on the first platform I tried PyTIFF on :(

> Let us know if you find something that works.
>
> Good luck!
>
> David

Thanks, appreciate the pointers, you'd found some stuff I'd overlooked, even about packages I found.

Glenn


More information about the PyQt mailing list