![](/img/trans.png)
[英]GdkPixbuf returns “gi._glib.GError: Couldn't recognize the image file format”
[英]glib.GError: Error interpreting JPEG image file (Unsupported marker type 0x05)
几年来我一直在使用gtk.gdk.PixbufLoader 。
今天,我尝试从新的Android设备加载jpg文件并获得此异常:
Traceback (most recent call last):
File "myscript.py", line 118, in next
loader.write(buf)
glib.GError: Error interpreting JPEG image file (Unsupported marker type 0x05)
可以在eog(gnome之眼)中加载相同的文件,我可以使用convert
(来自image-magick)而不出错。
它适用于所有文件,而不仅仅是一个,这使我得出结论文件没有被破坏。
可能有什么不对?
这是其中一个文件: http : //thomas-guettler.de/20160627_163057-0.jpg
这是一个重现异常的片段:
from gtk.gdk import PixbufLoader
pixbufloader=PixbufLoader()
chunksize=130000
fd=open('20160627_163057-0.jpg', 'rb')
while True:
bytes=fd.read(chunksize)
if not bytes:
break
print pixbufloader.write(bytes)
pixbufloader.close()
如果将chunksize
设置为1
,那么它可以工作。
如果我使用130000
作为chunksize,则第一次调用write()
失败。
我研究了你的代码并得出结论,正好在chunksize = 69632之后,即在chunksize = 69633,显示了这个错误。 我注意到的另一件事是这个错误与文件有关。如果我使用除“20160627_163057-0.jpg”图像之外的任何文件,则不会发生错误。
所以我的结论是这个特定的文件有一些问题。 请检查,谢谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.