I'm trying to change exif tags with ExifInterface. I use setAttribute() and call saveAttributes(). The tag is saved temporarily, then next time the old value is still there and hasn't been updated................
Example:
ExifInterface exifInterface = new ExifInterface(filePath);
String o1 = exifInterface.readAttribute(TAG_ORIENTATION); //o1 is "0"
exifInterface.setAttribute(TAG_ORIENTATION, "90");
exifInterface.saveAttributes();
String o2 = exifInterface.readAttribute(TAG_ORIENTATION); //o2 is "90"
// relaunch app, read attribute for same photo
String o3 = exifInterface.readAttribute(TAG_ORIENTATION); //o3 is "0" again, sould be "90"
Just in case someone is looking for a pure android solution: original code is correct, but value of TAG_ORIENTATION
attribute must be a value between 1 and 8, as explained in this page.
You must suppress the line with the call to readAttribute()
method, this method doesn't exist in the ExifInterface class. Replace it with exifInterface.getAttribute(ExifInterface.TAG_ORIENTATION, defaultValue)
if you want to read the value before and after the modification.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With