看來最好的辦法是不完全netpbm瘦,但使用Python:
import Image
import ImageFile
import subprocess
tiff = 'test.tiff'
im = Image.open(tiff)
print 'size', im.size
try:
print 'extrema', im.getextrema()
except IOError as e:
print 'help!', e, '\n'
print 'I Get by with a Little Help from my Friends'
pbm_proc = subprocess.Popen(['tifftopnm', tiff],
stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
(pbm_data, pbm_error) = pbm_proc.communicate()
ifp = ImageFile.Parser()
ifp.feed(pbm_data)
im = ifp.close()
print 'conversion message', pbm_error,
print 'extrema', im.getextrema()
print 'size', im.size
# houston: we have an image
im.show()
似乎做的伎倆:
$ python g3fax.py
size (1728, 2156)
extrema help! decoder group3 not available
I Get by with a Little Help from my Friends
conversion message tifftopnm: writing PBM file
extrema (0, 255)
size (1728, 2156)
來源
2010-07-28 23:52:51
msw
我試過tiffcp,雖然它轉換得很好,但圖片仍然沒有正確加載......我不知道你可以轉換爲lzw,但是...我會試試看......你能給我句法?? – tylerthemiler 2010-07-28 21:24:22
@tylerthemiler,沒有特別的語法,只是'tiffcp -c lzw from.tiff to.tiff'。而msw的回答有'subprocess'用法的例子。 – Constantin 2010-07-29 06:40:19