我使用uvccapture拍照并希望在python和python imaging library (PIL)的帮助下处理它们。 问题是PIL无法打开这些图像。 它抛出以下错误消息。
Traceback (most recent call last): File "process.py", line 6, in <module> im = Image.open(infile) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1980, in open raise IOError("cannot identify image file") IOError: cannot identify image file我的python代码如下所示:
import Image infile = "snap.jpg" im = Image.open(infile)在处理之前,我尝试以不同的格式保存图像。 但这没有用。 同时更改文件权限和所有者也无济于事。 唯一jpegoptim是打开图像,例如使用jpegoptim ,并用优化的图像覆盖旧图像。 在此过程之后, PIL可以处理这些图像。
这里有什么问题? uvccapture生成的文件是否uvccapture损坏?
//编辑:我也发现,用scipy打开用uvccapture生成的图像是不可能的。 运行命令
im = scipy.misc.imread("snap.jpg")产生相同的错误。
IOError: cannot identify image fileI use uvccapture to take pictures and want to process them with the help of python and the python imaging library (PIL). The problem is that PIL can not open those images. It throws following error message.
Traceback (most recent call last): File "process.py", line 6, in <module> im = Image.open(infile) File "/usr/lib/python2.7/dist-packages/PIL/Image.py", line 1980, in open raise IOError("cannot identify image file") IOError: cannot identify image fileMy python code looks like this:
import Image infile = "snap.jpg" im = Image.open(infile)I tried to save the images in different formats before processing them. But this does not help. Also changing file permissions and owners does not help. The only thing that helps is to open the images, for example with jpegoptim, and overwriting the old image with the optimized one. After this process, PIL can deal with these images.
What is the problem here? Are the files generated by uvccapture corrupt?
//EDIT: I also found out, that it is not possible to open the images, generated with uvccapture, with scipy. Running the command
im = scipy.misc.imread("snap.jpg")produces the same error.
IOError: cannot identify image file最满意答案
我只找到了解决这个问题的方法。 我使用jpegoptim处理捕获的图片,然后PIL可以处理优化的图像。
I only found a workaround to this problem. I processed the captured pic with jpegoptim and afterwords PIL could deal with the optimized image.
更多推荐
发布评论