jokiazhang / metadata-extractor

Automatically exported from code.google.com/p/metadata-extractor
0 stars 0 forks source link

Regression in ExifReader.processDirectory() #94

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi,

The JOSM project has found a regression when parsing the metadata of an image 
containing a GPSImgDirection tag. The tag was properly parsed with 
metadata-extractor 2.3 but no longer with 2.6.4. This issue has been fixed with 
the following patch:

http://josm.openstreetmap.de/changeset/6209/josm/trunk/src/com/drew/metadata/exi
f/ExifReader.java

This partially reverts a change introduced on 2001-05-01 in the commit 7bd15c8:

https://code.google.com/p/metadata-extractor/source/diff?spec=svn7bd15c8&old=052
cbf1&r=7bd15c8&format=unidiff&path=%2FSource%2Fcom%2Fdrew%2Fmetadata%2Fexif%2FEx
ifReader.java

I'm attaching an image exposing this issue, and here is the code to reproduce 
it:

    File file = new File("exif-direction-example.jpg");
    Metadata metadata = JpegMetadataReader.readMetadata(file);

    GpsDirectory dir = metadata.getDirectory(GpsDirectory.class); // null with 2.6.4
    Rational direction = dir.getRational(GpsDirectory.TAG_GPS_IMG_DIRECTION);

    System.out.println(direction); // should print "4650/100"

Original issue reported on code.google.com by emmanuel...@gmail.com on 27 Jun 2014 at 3:17

Attachments:

GoogleCodeExporter commented 9 years ago
I sympathise with the desire to continue processing after observing a violation 
of the specification like that in this image. Some points to note:

- Applying the patch from JSOM causes metadata-extractor to produce rubbish 
when proccessing some other images such as those from the Olympus Pen. In those 
images data which is clearly not valid TIFF is processed and a lot of rubbish 
output is produced.
- This particular image may have been manipulated in some software which caused 
this error, as another Sony DSC-HX5V image in the sample library processes fine.

Regardless of how the error ended up in this file, it would be nice to have a 
good heuristic for knowing when it is safe to continue reading from a file 
versus when garbage is being processed.

'exiftool' does a good job of processing the file you've attached. I'd like to 
see how they handle such errors.

Original comment by drewnoakes on 21 Nov 2014 at 9:45

GoogleCodeExporter commented 9 years ago
This issue has been migrated along with the project to GitHub:

https://github.com/drewnoakes/metadata-extractor/issues/28

Original comment by drewnoakes on 21 Nov 2014 at 9:54