diff --git a/Source/com/drew/lang/Rational.java b/Source/com/drew/lang/Rational.java index a172e0583..79601cecb 100644 --- a/Source/com/drew/lang/Rational.java +++ b/Source/com/drew/lang/Rational.java @@ -167,6 +167,16 @@ public Rational getReciprocal() return new Rational(this._denominator, this._numerator); } + /** + * Returns the absolute value of this object as a new Rational. + * + * @return the absolute value in a new object + */ + public Rational getAbsolute() + { + return new Rational(Math.abs(this._numerator), Math.abs(this._denominator)); + } + /** Checks if this {@link Rational} number is an Integer, either positive or negative. */ public boolean isInteger() { @@ -181,6 +191,12 @@ public boolean isZero() return _numerator == 0 || _denominator == 0; } + /** True if the value is non-zero and numerator and denominator are either both positive or both negative. */ + public boolean isPositive() + { + return !isZero() && (_numerator > 0 == _denominator > 0); + } + /** * Returns a string representation of the object of form numerator/denominator. * diff --git a/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDescriptor.java b/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDescriptor.java index 94ea50bf9..25dc08e90 100644 --- a/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDescriptor.java +++ b/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDescriptor.java @@ -20,6 +20,7 @@ */ package com.drew.metadata.exif.makernotes; +import com.drew.lang.Rational; import com.drew.lang.annotations.NotNull; import com.drew.lang.annotations.Nullable; import com.drew.metadata.TagDescriptor; @@ -46,6 +47,8 @@ public String getDescription(int tagType) switch (tagType) { case AppleMakernoteDirectory.TAG_HDR_IMAGE_TYPE: return getHdrImageTypeDescription(); + case AppleMakernoteDirectory.TAG_ACCELERATION_VECTOR: + return getAccelerationVectorDescription(); default: return super.getDescription(tagType); } @@ -56,4 +59,15 @@ public String getHdrImageTypeDescription() { return getIndexedDescription(AppleMakernoteDirectory.TAG_HDR_IMAGE_TYPE, 3, "HDR Image", "Original Image"); } + + @Nullable + public String getAccelerationVectorDescription() + { + Rational[] values = _directory.getRationalArray(AppleMakernoteDirectory.TAG_ACCELERATION_VECTOR); + if (values == null || values.length != 3) + return null; + return String.format("%.2fg %s, ", values[0].getAbsolute().doubleValue(), values[0].isPositive() ? "left" : "right") + + String.format("%.2fg %s, ", values[1].getAbsolute().doubleValue(), values[1].isPositive() ? "down" : "up") + + String.format("%.2fg %s", values[2].getAbsolute().doubleValue(), values[2].isPositive() ? "forward" : "backward"); + } } diff --git a/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDirectory.java b/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDirectory.java index 44e8eb862..bf10a94ae 100644 --- a/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDirectory.java +++ b/Source/com/drew/metadata/exif/makernotes/AppleMakernoteDirectory.java @@ -36,8 +36,11 @@ public class AppleMakernoteDirectory extends Directory { public static final int TAG_RUN_TIME = 0x0003; + public static final int TAG_ACCELERATION_VECTOR = 0x0008; public static final int TAG_HDR_IMAGE_TYPE = 0x000a; public static final int TAG_BURST_UUID = 0x000b; + public static final int TAG_CONTENT_IDENTIFIER = 0x0011; + public static final int TAG_IMAGE_UNIQUE_ID = 0x0015; @NotNull private static final HashMap _tagNameMap = new HashMap(); @@ -45,8 +48,11 @@ public class AppleMakernoteDirectory extends Directory static { _tagNameMap.put(TAG_RUN_TIME, "Run Time"); + _tagNameMap.put(TAG_ACCELERATION_VECTOR, "Acceleration Vector"); _tagNameMap.put(TAG_HDR_IMAGE_TYPE, "HDR Image Type"); _tagNameMap.put(TAG_BURST_UUID, "Burst UUID"); + _tagNameMap.put(TAG_CONTENT_IDENTIFIER, "Content Identifier"); + _tagNameMap.put(TAG_IMAGE_UNIQUE_ID, "Image Unique ID"); } public AppleMakernoteDirectory()