Writing EXIF metadata to images in Android
Ok, Somebody (offline) pointed me to a useful resource. The ExifInterface
looks like what I was searching for. Android-er has a post demonstrating how to read EXIF metadata in Android and I think writing should not be very different.
I don't know, but can we EXIF to write arbitrary metadata, ie. other than those specified in the ExifInterface documentation (like latitude, longitude, flash etc). If not, what could be a preferred method of writing arbitrary metadata to image files?
Thanks
public static void writeFile (File photo, double latitude, double longitude) throws IOException{ ExifInterface exif = null; try{ Log.v("latiDouble", ""+latitude); Log.v("longiDouble", ""+longitude); exif = new ExifInterface(photo.getCanonicalPath()); if (exif != null) { double latitu = latitude; double longitu = longitude; double alat = Math.abs(latitu); double along = Math.abs(longitu); String stringLati = convertDoubleIntoDegree(alat); String stringLongi = convertDoubleIntoDegree(along); exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, stringLati); exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, stringLongi); Log.v("latiString", ""+ stringLati); Log.v("longiString", ""+ stringLongi); exif.saveAttributes(); String lati = exif.getAttribute (ExifInterface.TAG_GPS_LATITUDE); String longi = exif.getAttribute (ExifInterface.TAG_GPS_LONGITUDE); Log.v("latiResult", ""+ lati); Log.v("longiResult", ""+ longi); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }}
I copied the answer from here