Index of /software_projects/2004/pytiff

[ICO]NameLast modifiedSizeDescription

[DIR]Parent Directory  -  
[TXT]README.html28-Feb-2011 01:06 5.5K 
[TXT]python-style.css28-Feb-2005 00:59 211  
[   ]pytiff-0.1.6.tar.gz13-Jun-2005 01:29 2.8M 
[TXT]pytiff.html07-Jul-2005 02:32 41K 



PyTIFF is a library for using TIFF files and advanced imaging in Python. To install pytiff, download the current tar.gz archive and unpack in a directory of your choice. Then, provided you have the necessary software installed, you can install pytiff with python install, or type python --help for more information. The library is documented in pytiff.html. Have fun!


How do I encode an image with a specific compression method?

You can determine how an image will be compressed by setting an appropriate value for the 'compression' key in its metadata. Here is an example to convert all images of a TIFF file to G4 compression. (This will, of course, fail if the source images aren't black and white.)

import pytiff

class AttrChangeFilter:
    def __init__(self, image, new_metadata):
        self.image = image
        self.new_metadata = new_metadata
    def __getattr__(self, attr):
        return getattr(self.image, attr)
    def get_metadata(self):
        return self.new_metadata
    metadata = property(get_metadata, None, None)

r = pytiff.TiffReader("infile.tiff")
w = pytiff.TiffWriter("outfile.tiff")

for p in r:
    m = dict(p.metadata)
    m["compression"] = "T6"
    p = AttrChangeFilter(p, m)

Licensing Terms

Copyright © 2005 by Oliver M. Haynold

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Last modified: Wed Feb 23 01:38:38 CST 2005