summaryrefslogtreecommitdiffstats
path: root/gallerycommon/src/com/android/gallery3d/exif
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
commitd16187301386ce1234a57fa6da9f805624227570 (patch)
tree602aa001c0311374cd30ebda297f875820b31298 /gallerycommon/src/com/android/gallery3d/exif
parentb9107fdcf2c17bebc4eeb0e13c92ba5f301f52b6 (diff)
downloadandroid_packages_apps_Snap-d16187301386ce1234a57fa6da9f805624227570.zip
android_packages_apps_Snap-d16187301386ce1234a57fa6da9f805624227570.tar.gz
android_packages_apps_Snap-d16187301386ce1234a57fa6da9f805624227570.tar.bz2
Added check to strip out uninitialized EXIF tags.
Bug: 8552339 Change-Id: Ib6ae4f59f9e393e5f6b46877a4b2c3b2fe1852d3
Diffstat (limited to 'gallerycommon/src/com/android/gallery3d/exif')
-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 ae501a5..7ca05f2 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 {