summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com
diff options
context:
space:
mode:
authorRuben Brunk <rubenbrunk@google.com>2013-04-05 16:22:55 -0700
committerRuben Brunk <rubenbrunk@google.com>2013-04-05 16:34:18 -0700
commita0c21c94c35865b0464cae27436f21d50ff1eb31 (patch)
tree50f96c8df413ef972262f89e7b545d12be6208f3 /gallerycommon/src/com
parent93d76a69aecf03e7ac7653bd088fe6bb64356ec1 (diff)
downloadandroid_packages_apps_Snap-a0c21c94c35865b0464cae27436f21d50ff1eb31.tar.gz
android_packages_apps_Snap-a0c21c94c35865b0464cae27436f21d50ff1eb31.tar.bz2
android_packages_apps_Snap-a0c21c94c35865b0464cae27436f21d50ff1eb31.zip
Added check to strip out uninitialized EXIF tags.
Bug: 8552339 Change-Id: Ib6ae4f59f9e393e5f6b46877a4b2c3b2fe1852d3
Diffstat (limited to 'gallerycommon/src/com')
-rw-r--r--gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java16
1 files changed, 16 insertions, 0 deletions
diff --git a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
index ae501a50f..7ca05f2e0 100644
--- a/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
+++ b/gallerycommon/src/com/android/gallery3d/exif/ExifOutputStream.java
@@ -24,6 +24,7 @@ import java.io.IOException;
import java.io.OutputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
+import java.util.ArrayList;
/**
* This class provides a way to replace the Exif header of a JPEG image.
@@ -212,6 +213,7 @@ class ExifOutputStream extends FilterOutputStream {
if (DEBUG) {
Log.v(TAG, "Writing exif data...");
}
+ ArrayList<ExifTag> nullTags = stripNullValueTags(mExifData);
createRequiredIfdAndTag();
int exifSize = calculateAllOffset();
if (exifSize + 8 > MAX_EXIF_SIZE) {
@@ -233,6 +235,20 @@ class ExifOutputStream extends FilterOutputStream {
dataOutputStream.writeInt(8);
writeAllTags(dataOutputStream);
writeThumbnail(dataOutputStream);
+ for (ExifTag t : nullTags) {
+ mExifData.addTag(t);
+ }
+ }
+
+ private ArrayList<ExifTag> stripNullValueTags(ExifData data) {
+ ArrayList<ExifTag> nullTags = new ArrayList<ExifTag>();
+ for(ExifTag t : data.getAllTags()) {
+ if (t.getValue() == null && !ExifInterface.isOffsetTag(t.getTagId())) {
+ data.removeTag(t.getTagId(), t.getIfd());
+ nullTags.add(t);
+ }
+ }
+ return nullTags;
}
private void writeThumbnail(OrderedDataOutputStream dataOutputStream) throws IOException {