X-Git-Url: https://gitweb.fperrin.net/?p=GpsPrune.git;a=blobdiff_plain;f=tim%2Fprune%2Fdrew%2Fjpeg%2FExifReader.java;h=0084b87b169a6b0913f386e677c34e15aaeb757f;hp=9e0fd5980fd0f33fa64a61a46b0db6fc345c53b4;hb=1ee49ae3c8ef3aa2e63eadd458531e5f8bd4f92c;hpb=112bb0c9b46894adca9a33ed8c99ea712b253185 diff --git a/tim/prune/drew/jpeg/ExifReader.java b/tim/prune/drew/jpeg/ExifReader.java index 9e0fd59..0084b87 100644 --- a/tim/prune/drew/jpeg/ExifReader.java +++ b/tim/prune/drew/jpeg/ExifReader.java @@ -78,6 +78,8 @@ public class ExifReader private static final int TAG_THUMBNAIL_OFFSET = 0x0201; /** Thumbnail length */ private static final int TAG_THUMBNAIL_LENGTH = 0x0202; + /** Orientation of image */ + private static final int TAG_ORIENTATION = 0x0112; /** @@ -383,6 +385,11 @@ public class ExifReader _thumbnailLength = get16Bits(inTagValueOffset); extractThumbnail(inMetadata); } + else if (inTagType == TAG_ORIENTATION) { + if (inMetadata.getOrientationCode() < 1) { + inMetadata.setOrientationCode(get16Bits(inTagValueOffset)); + } + } } /** @@ -411,7 +418,7 @@ public class ExifReader if (inByteCount > 4) { // If it's bigger than 4 bytes, the dir entry contains an offset. - // dirEntryOffset must be passed, as some makernote implementations (e.g. FujiFilm) incorrectly use an + // dirEntryOffset must be passed, as some makers (e.g. FujiFilm) incorrectly use an // offset relative to the start of the makernote itself, not the TIFF segment. final int offsetVal = get32Bits(inDirEntryOffset + 8); if (offsetVal + inByteCount > _data.length) @@ -506,7 +513,8 @@ public class ExifReader private int get16Bits(int offset) { if (offset<0 || offset+2>_data.length) - throw new ArrayIndexOutOfBoundsException("attempt to read data outside of exif segment (index " + offset + " where max index is " + (_data.length - 1) + ")"); + throw new ArrayIndexOutOfBoundsException("attempt to read data outside of exif segment (index " + + offset + " where max index is " + (_data.length - 1) + ")"); if (_isMotorolaByteOrder) { // Motorola - MSB first