Reputation: 24094
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"
Upvotes: 7
Views: 10351
Reputation: 855
Try this:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED, Uri.parse("file://"+ Environment.getExternalStorageDirectory())));
Upvotes: 0
Reputation: 3814
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.
Upvotes: 8
Reputation: 11
You should use something like
exifInterface.setAttribute(TAG_ORIENTATION, ""+ExifInterface.ORIENTATION_ROTATE_90);
instead
Upvotes: 1