Neo*_*ang 32 python image-formats python-imaging-library
使用PIL.Image加载图像文件后,如何确定图像文件是否为PNG/JPG/BMP/GIF?我对这些文件格式了解甚少,PIL可以format从文件头获取元数据吗?或者是否需要"分析"文件中的数据?
如果PIL没有提供这样的API,那么有没有python库呢?
Mik*_*maa 62
尝试:
img = Image.open(filename)
print(img.format) # 'JPEG'
Run Code Online (Sandbox Code Playgroud)
更多信息
http://pillow.readthedocs.org/en/latest/reference/Image.html#PIL.Image.format
http://pillow.readthedocs.org/en/latest/handbook/image-file-formats.html
| 归档时间: |
|
| 查看次数: |
27007 次 |
| 最近记录: |