python IOError: cannot identify image file
来源:互联网 发布:linux l2tp server 编辑:程序博客网 时间:2024/06/07 02:41
Python 做图像处理,输出一副图片的大小。代码如下:
- 1
- 2
- 3
- 1
- 2
- 3
运行报错:IOError: cannot identify image file ‘D:\pythonword\tt.jpg’
逐步分析报错原因:
(1)首先确定自己pillow文件成功安装(用easy_install和pip安装,具体安装步骤可参考我的另外一篇博客:http://blog.csdn.net/sinat_25704999/article/details/49976137)
(2)python中文件路径需要将\改写为/或者\,在上述代码中D:\pythonword\tt.jpg写法是正确的,tt.jpg是正常的图片,在浏览器中输入此地址也可以正常打开该图片,所以文件路径没有问题。
(3)不只是JPEG的格式,PNG等图片文件格式都报同样的错误。
用from PIL import Image代替import Image后,代码运行成功,显示了图片的大小。
总结:
PIL(Python Imaging Library)因常年没有更新,也不能适用于新版本的python,于是Pillow应运而生。但是Pillow由PIL而来,所以导入相关文件(以Image为例)不能写作:import Image,而是要写成 from PIL import Image。
0 0
- python IOError: cannot identify image file
- python IOError: cannot identify image file
- Python代码调试问题:IOError: cannot identify image file
- PIL IOError: cannot identify image file 'images/1212.jpg'的解决办法
- 如何安装PIL--*** TKINTER support not available---IOError: cannot identify image file
- Image.open() cannot identify image file
- 出现“cannot identify image file '/Users//.DS_Store'”问题解决的办法
- ORA-01157: cannot identify/lock data file
- Python IOError: File not open for writing
- ORA-01157: cannot identify/lock data file - see DBWR tracefile
- ORA-01157报错"cannot identify/lock data file"解决
- ORA-01157: cannot identify/lock data file 7
- ORA-1157, cannot identify/lock data file - see DBWR trace file
- ORA-01157: cannot identify/lock data file 27 - see DBWR trace file
- ORA-01157: cannot identify/lock data file 12 - see DBWR trace file
- 【续】ORA-01157: cannot identify/lock data file 6 - see DBWR trace file ORA-01110: 解决方法
- 【精】ORA-01157: cannot identify/lock data file 6 - see DBWR trace file ORA-01110: 解决方法
- ORA-01157: cannot identify/lock data file 6 - see DBWR trace file
- 案例一,查询网络图片
- Redis基础学习--脚本(Lua语言)
- Hibernate框架总结
- 世界Tree
- 遗传算法的入门实现(2):利用正方形拼接firefox
- python IOError: cannot identify image file
- Mybatis的mapper.xml文件详解
- eclipse 4.2.0的安装如何更改jdk环境变量(name=Eclipse Platform id=org.eclipse.platform version=4.2.0)
- Unity&Shader高级案例篇—图形命令缓冲
- Action中取得request,session的四种方式
- 计算机图形学(循环菱形、循环嵌套矩形)
- 如何实现1080P延迟低于500ms的实时超清直播传输技术
- [FUNC]为AutoHotkey写个print函数
- POJ 2488 A Knight's Journey__深搜