Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ExifInterface doesn't update exif tags

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"
like image 411
siamii Avatar asked Mar 03 '11 21:03

siamii


1 Answers

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.

like image 151
eternay Avatar answered Sep 18 '22 09:09

eternay