Using TIFF G4 image in PIL

2019-03-01 07:34发布

问题:

I wrote a pure python TIFF G4 decompress for use with tifffile.py. I know there are ways to add libtiff to a custom PIL, but I never could get that working very well in a mixed virtualenv. I want to manipulate the image in PIL. I am looking for pointers in hooking my decompressor to stock PIL for TiffImagePlugin.py.

Any ideas?

回答1:

It appears that TiffImagePlugin does not easily allow me to hook in additional decompressors. Replacing TiffImageFile._decoder with a dictionary of decoders might work, but you would have to examine and test each release of PIL to ensure it hasn't broken. This level of maintenance is just as bad as a custom PIL. I appreciate the design of tifffile.py for using a dictionary of decoders. It made it very easy.

Final solution? I couldn't hook my code into PIL. I had to use PIL.Image.fromarray() to using my decompressed images.