Add Metadata To Created Bitmap In Android
I am using a camera intent to take pictures, then I convert that image to a bytearray and eventually save it locally in my database. The original image taken with the camera has al
Solution 1:
Meta data is not a property of bitmap. it is stored as Exinf of JPEG file. use ExifInterface to update meta data here is an example to set gps cordinates
exif = new ExifInterface(imageFile.getAbsolutePath());
int num1Lat = (int) Math.floor(latitude);
int num2Lat = (int) Math.floor((latitude - num1Lat) * 60);
double num3Lat = (latitude - ((double) num1Lat + ((double) num2Lat / 60))) * 3600000;
int num1Lon = (int) Math.floor(longitude);
int num2Lon = (int) Math.floor((longitude - num1Lon) * 60);
double num3Lon = (longitude - ((double) num1Lon + ((double) num2Lon / 60))) * 3600000;
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE, num1Lat + "/1," + num2Lat + "/1," + num3Lat + "/1000");
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE, num1Lon + "/1," + num2Lon + "/1," + num3Lon + "/1000");
if (latitude > 0) {
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "N");
} else {
exif.setAttribute(ExifInterface.TAG_GPS_LATITUDE_REF, "S");
}
if (longitude > 0) {
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "E");
} else {
exif.setAttribute(ExifInterface.TAG_GPS_LONGITUDE_REF, "W");
}
exif.setAttribute(ExifInterface.TAG_MAKE, "FooBarr");
exif.setAttribute(ExifInterface.TAG_MODEL, "KooKKoo");
exif.setAttribute(ExifInterface.TAG_ORIENTATION,orientation+"");
exif.saveAttributes();
Post a Comment for "Add Metadata To Created Bitmap In Android"