use*_*339 7 python tiff image-processing python-imaging-library
我知道PIL Image.seek()和Image.tell()PIL的方法允许我去一个特定的帧,并分别列出当前帧.我想知道总共有多少帧.是否有获取此信息的功能?或者,在python中是否有一种方法可以创建循环并捕获在没有图像时发生的错误?
from PIL import Image
videopath = '/Volumes/USB20FD/test.tif'
print "Using PIL to open TIFF"
img = Image.open(videopath)
img.seek(0) # .seek() method allows browsing multi-page TIFFs, starting with 0
im_sz = [img.tag[0x101][0], img.tag[0x100][0]]
print "im_sz: ", im_sz
print "current frame: ", img.tell()
print img.size()
Run Code Online (Sandbox Code Playgroud)
在上面的代码中,我打开一个TIFF堆栈,并访问第一帧.我需要知道堆栈的"深度",因此如果不存在图像,我不会在下游计算中出现错误.
如果您可以等到2015年7月1日,Pillow的下一个版本(PIL前叉)将允许您使用它来检查n_frames.
如果您不能等到那时,您可以复制该实现,修补您自己的版本或使用最新的开发版本.
更多信息:https: //github.com/python-pillow/Pillow/pull/1261
| 归档时间: |
|
| 查看次数: |
2189 次 |
| 最近记录: |