incubator-sanselan-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cmc...@apache.org
Subject svn commit: r790022 - in /incubator/sanselan/trunk: RELEASE_NOTES src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java
Date Wed, 01 Jul 2009 02:03:20 GMT
Author: cmchen
Date: Wed Jul  1 02:03:20 2009
New Revision: 790022

URL: http://svn.apache.org/viewvc?rev=790022&view=rev
Log:
* Fixed a problem in the metadata example code not using exact matching for GPS values.

Modified:
    incubator/sanselan/trunk/RELEASE_NOTES
    incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java
    incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java

Modified: incubator/sanselan/trunk/RELEASE_NOTES
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/RELEASE_NOTES?rev=790022&r1=790021&r2=790022&view=diff
==============================================================================
--- incubator/sanselan/trunk/RELEASE_NOTES (original)
+++ incubator/sanselan/trunk/RELEASE_NOTES Wed Jul  1 02:03:20 2009
@@ -14,6 +14,7 @@
 
 Next Release
 ------------
+ * Fixed a problem in the metadata example code not using exact matching for GPS values.
  * Fixed a possible NPE in Sanselan.getICCProfile pointed out by Jon Weygandt.
  * Fixed a bug in which gifs have incorrect size information in the the Logical Screen Descriptor.
    This appears to be a bug in how Microsoft Office writes gifs.

Modified: incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java?rev=790022&r1=790021&r2=790022&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java
(original)
+++ incubator/sanselan/trunk/src/main/java/org/apache/sanselan/formats/jpeg/JpegImageMetadata.java
Wed Jul  1 02:03:20 2009
@@ -47,6 +47,22 @@
 	}
 
 	public TiffField findEXIFValue(TagInfo tagInfo) {
+		TiffField field = findEXIFValue(tagInfo, true);
+		if (field == null) {
+			// In some cases, we want an exact directory match (such as GPS values).
+			// In other cases, we are more permissive (ie. with tags that may appear 
+			// in a number of different directories, depending on the camera manufacturer, etc.
+			// TODO: Modify TagInfo class to include a "permissive/exact" flag.
+			field = findEXIFValue(tagInfo, false);
+		}
+		return field;
+	}
+
+	public TiffField findEXIFValueWithExactMatch(TagInfo tagInfo) {
+		return findEXIFValue(tagInfo, true);
+	}
+
+	private TiffField findEXIFValue(TagInfo tagInfo, boolean requireDirectoryMatch) {
 		ArrayList items = getItems();
 		for (int i = 0; i < items.size(); i++) {
 			Object o = items.get(i);
@@ -55,6 +71,10 @@
 
 			TiffImageMetadata.Item item = (TiffImageMetadata.Item) o;
 			TiffField field = item.getTiffField();
+			if (requireDirectoryMatch &&
+					(field.directoryType != tagInfo.directoryType.directoryType)) {
+				continue;
+			}
 			if (field.tag == tagInfo.tag)
 				return field;
 		}

Modified: incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java
URL: http://svn.apache.org/viewvc/incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java?rev=790022&r1=790021&r2=790022&view=diff
==============================================================================
--- incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java
(original)
+++ incubator/sanselan/trunk/src/test/java/org/apache/sanselan/sampleUsage/MetadataExample.java
Wed Jul  1 02:03:20 2009
@@ -83,7 +83,7 @@
 					double longitude = gpsInfo.getLongitudeAsDegreesEast();
 					double latitude = gpsInfo.getLatitudeAsDegreesNorth();
 
-					System.out.println("	" + "GPS Description: " + gpsInfo);
+					System.out.println("	" + "GPS Description: " + gpsDescription);
 					System.out.println("	" + "GPS Longitude (Degrees East): " + longitude);
 					System.out.println("	" + "GPS Latitude (Degrees North): " + latitude);
 				}
@@ -91,13 +91,13 @@
 
 			// more specific example of how to manually access GPS values
 			TiffField gpsLatitudeRefField = jpegMetadata
-					.findEXIFValue(TiffConstants.GPS_TAG_GPS_LATITUDE_REF);
+					.findEXIFValueWithExactMatch(TiffConstants.GPS_TAG_GPS_LATITUDE_REF);
 			TiffField gpsLatitudeField = jpegMetadata
-					.findEXIFValue(TiffConstants.GPS_TAG_GPS_LATITUDE);
+					.findEXIFValueWithExactMatch(TiffConstants.GPS_TAG_GPS_LATITUDE);
 			TiffField gpsLongitudeRefField = jpegMetadata
-					.findEXIFValue(TiffConstants.GPS_TAG_GPS_LONGITUDE_REF);
+					.findEXIFValueWithExactMatch(TiffConstants.GPS_TAG_GPS_LONGITUDE_REF);
 			TiffField gpsLongitudeField = jpegMetadata
-					.findEXIFValue(TiffConstants.GPS_TAG_GPS_LONGITUDE);
+					.findEXIFValueWithExactMatch(TiffConstants.GPS_TAG_GPS_LONGITUDE);
 			if (gpsLatitudeRefField != null && gpsLatitudeField != null
 					&& gpsLongitudeRefField != null
 					&& gpsLongitudeField != null)
@@ -153,7 +153,7 @@
 	private static void printTagValue(JpegImageMetadata jpegMetadata,
 			TagInfo tagInfo) throws ImageReadException, IOException
 	{
-		TiffField field = jpegMetadata.findEXIFValue(tagInfo);
+		TiffField field = jpegMetadata.findEXIFValueWithExactMatch(tagInfo);
 		if (field == null)
 			System.out.println(tagInfo.name + ": " + "Not Found.");
 		else



Mime
View raw message