Merge pull request #1321 from laurisaarni/add-missing-exifdata

Add the missing exif data for Android
This commit is contained in:
Sibelius Seraphini 2018-03-08 17:19:14 -03:00 committed by GitHub
commit f735733b1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -15,6 +15,7 @@ import com.drew.metadata.Metadata;
import com.drew.metadata.MetadataException;
import com.drew.metadata.Tag;
import com.drew.metadata.exif.ExifIFD0Directory;
import com.drew.metadata.exif.ExifSubIFDDirectory;
import com.facebook.react.bridge.ReadableMap;
import java.io.BufferedInputStream;
@ -179,7 +180,6 @@ public class MutableImage {
ExifInterface exif = new ExifInterface(file.getAbsolutePath());
// copy original exif data to the output exif...
// unfortunately, this Android ExifInterface class doesn't understand all the tags so we lose some
for (Directory directory : originalImageMetaData().getDirectories()) {
for (Tag tag : directory.getTags()) {
int tagType = tag.getTagType();
@ -188,6 +188,18 @@ public class MutableImage {
}
}
// Add missing exif data from a sub directory
ExifSubIFDDirectory directory = originalImageMetaData()
.getFirstDirectoryOfType(ExifSubIFDDirectory.class);
for (Tag tag : directory.getTags()) {
int tagType = tag.getTagType();
// As some of exif data does not follow naming of the ExifInterface the names need
// to be transformed into Upper camel case format.
String tagName = tag.getTagName().replaceAll(" ", "");
Object object = directory.getObject(tagType);
exif.setAttribute(tagName, object.toString());
}
writeLocationExifData(options, exif);
if(hasBeenReoriented)