rwcarlsen/goexif — pull request #28 by mpl (2014-09-23 22:46:54+00:00)
Title: return specific error types for sub-IFDs

Context: https://code.google.com/p/camlistore/issues/detail?id=493

We have some Camlistore users reporting that they have pictures on which we choke. It looks like goexif is rightly having a problem processing a badly formed tiff tag type in at least the first case, and that's fine.

However, I think they do have a point when they compare the result with some other tools that do report the error ("Warning: Bad InteropIFD directory" from exiftool), but still give whatever useful info was extracted from the (broken) file.

So I'd like to propose a mechanism to return some specific error types, so that we know when it's still possible to use whatever was decoded by goexif in some cases. Something like:

ex, err := exif.Decode(f)
if err != nil {
if !exif.IsGPSInfoError(err) && !exif.IsInteroperabilityError(err) {
log.Fatalf("exif.Decode: %v", err)
}
}
// else try and use ex anyway to get e.g. DateTime info.

I've just toyed with this idea and this commit is maybe a bit gross. If you're ok with the concept then I'll try and think of a better implementation.