rwcarlsen / goexif

Decode embedded EXIF meta data from image files.
BSD 2-Clause "Simplified" License
627 stars 134 forks source link

bugs: fix dataLen calculation, avoid EOF when dealing with small pics #6

Closed mpl closed 11 years ago

mpl commented 11 years ago

Hi,

I think I fixed a couple of bugs we stumbled upon because our test cases involve tiny pics.

I tried to stay the least intrusive possible so they may not be the best fixes and you might want to rework that. But it should give you an idea of the problem.

You can find examples of the small pics I'm talking about here: http://camlistore.org/code/?p=camlistore.git;a=tree;f=pkg/images/testdata;hb=HEAD

rwcarlsen commented 11 years ago

As far as I can tell from reconsulting the JFIF and EXIF specs, the two bytes following section markers are responsible for holding an accurate section length. I will push a patch fixing the EOF problem with short files (the upper loop), the missing dataLen=len(app.data) and a few minor tweaks. We can discuss the lower loop case further if you like, or you can just maintain a patch handling it in your own fork.

mpl commented 11 years ago

hmm, from your last comment I fear we have badly misunderstood each other, I should probably have explained more what the problems I saw were. I'll try that latest change soon.

rwcarlsen commented 11 years ago

I reworked the function - cleaned it up and used the bufio Reader (new go1 branch head 7cecb9b). I ran it on a ~5000 pic lib I have and all your test pics. It seems to be working well.

mpl commented 11 years ago

Thanks, I'll check it out tomorrow.