口齿伶俐的。GError:解释JPEG图像文件的错误(不支持的标记类型0x05)

时间:2021-12-07 21:20:34

I am using gtk.gdk.PixbufLoader since several years.

我用gtk.gdk。几年以来PixbufLoader。

Today, I try to load a jpg file from a new android device and get this exception:

今天,我尝试从一个新的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)

The same file can be loaded in eog (eye of gnome) and I can use convert (from image-magick) with out error.

同样的文件可以在eog (gnome之眼)中加载,我可以使用convert (from image-magick)而不出错。

It happens for all files, not just one, this leads me to the conclusion that the files are not broken.

它发生在所有的文件中,而不仅仅是一个文件,这使我得出这样的结论:文件没有被破坏。

What could be wrong?

可能是错的呢?

Here is one of the files: http://thomas-guettler.de/20160627_163057-0.jpg

下面是其中一个文件:http://thomas-guettler.de/20160627_163057-0.jpg

Here is a snippet to reproduce the exception:

下面是一个复制异常的片段:

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()

If you set chunksize to 1, then it works.

如果您将chunksize设置为1,那么它是有效的。

If I use 130000 as chunksize, then the first call to write() fails.

如果我使用130000作为chunksize,则写入()的第一个调用将失败。

1 个解决方案

#1


5  

I worked on your code and got to the conclusion that exactly after chunksize = 69632,i.e. at chunksize = 69633,This error is shown. One more thing I noticed is that this error is file related.If I use any file other than this "20160627_163057-0.jpg" image,error does not occur.

我研究了你的代码,得出的结论是恰好在chunksize = 69632之后。在chunksize = 69633处,显示此错误。我还注意到,这个错误与文件有关。如果我使用“20160627_163057-0.jpg”图像以外的任何文件,则不会出现错误。

So my conclusion is that this particular file has some problem. Please check, Thanks.

我的结论是这个文件有一些问题。请检查,谢谢。

#1


5  

I worked on your code and got to the conclusion that exactly after chunksize = 69632,i.e. at chunksize = 69633,This error is shown. One more thing I noticed is that this error is file related.If I use any file other than this "20160627_163057-0.jpg" image,error does not occur.

我研究了你的代码,得出的结论是恰好在chunksize = 69632之后。在chunksize = 69633处,显示此错误。我还注意到,这个错误与文件有关。如果我使用“20160627_163057-0.jpg”图像以外的任何文件,则不会出现错误。

So my conclusion is that this particular file has some problem. Please check, Thanks.

我的结论是这个文件有一些问题。请检查,谢谢。