1

我正在尝试为我的 TIFF 数据库创建结构化的 JPG 预览,但集合中的大多数文件都是 LZW 压缩的。我正在使用此代码打开 TIFF 文件

import os
import sys
from PIL import Image

curdir = os.path.dirname(os.path.abspath(__file__))
fname = 'TIFF - LZW - sample.tif'
#fname = 'TIFF - uncompressed - sample.tif'

jpg_size = 1200, 1200

tif = Image.open(os.path.join(curdir,fname))
tif.thumbnail(jpg_size)
tif.save(os.path.splitext(os.path.join(curdir, fname))[0] + '.jpg', 'JPEG', quality = 80)  

input('OK!')

使用未压缩的样本完全可以,但是使用 LZW TIFF 代码返回错误:

Traceback (most recent call last):
  File "APR - script - TIFF test.py", line 15, in <module>
    tif = Image.open(os.path.join(curdir,fname))
  File "C:\Python27\lib\site-packages\PIL\Image.py", line 2286, in open
    % (filename if filename else fp))
IOError: cannot identify image file 'D:\\SCRIPT\\TIFF\\TIFF - LZW - sample.tif'

我在 Windows 7 中使用 Python 2.7

我已经做了什么:

是否有可能仍然不支持这种压缩?或者我如何检查 PILLOW 是否找到了 LIBTIFF 库并且它真的有效?

也许TIFF文件还有另一个问题?

也许任何其他建议没有我如何使用 Python 将 LZW TIFF 转换为 JPG 预览?

https://dl.dropboxusercontent.com/u/24531139/TIFF%20-%20LZW%20-%20sample.tif - 我的 tiff 文件

4

0 回答 0