问题描述
我写了一个纯Python的TIFF G4解压缩程序,供tifffile.py
使用.我知道有多种方法可以将libtiff
添加到自定义PIL中,但是在混合virtualenv中,我永远无法使它很好地工作.我想在PIL中处理图像.我正在寻找将我的解压缩器挂接到TiffImagePlugin.py
的PIL的指针.
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
.
有什么想法吗?
推荐答案
似乎TiffImagePlugin
不能轻易让我挂接其他解压缩器.用解码器字典替换TiffImageFile._decoder
可能可行,但是您必须检查并测试每个PIL版本以确保它没有损坏.这种维护水平与自定义PIL一样糟糕.我感谢使用解码器字典的tifffile.py
设计.这非常容易.
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.
最终解决方案?我无法将我的代码连接到PIL中.我必须使用PIL.Image.fromarray()
来使用解压缩的图像.
Final solution? I couldn't hook my code into PIL. I had to use PIL.Image.fromarray()
to using my decompressed images.
这篇关于在PIL中使用TIFF G4图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!