How to remove exif tags using Android ExifInterface
I am currently working on an Android app that has a feature to remove EXIF ββtags. The Android built-in library (android.media.ExifInterface) does not allow this. This is only possible for editing existing values. So I thought I could overwrite them with an empty value like empty string, space, zero. The tags in the EXIF ββspec are of different types and I cannot overwrite them with the same value.
See: http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/EXIF.html
After some testing, I replaced the data with the blank values ββbelow (in the format they were shown at the beginning). In the comments, I have indicated the types of the corresponding tags.
private static final Map<String, String> emptyValues = new HashMap<String, String>();
static {
emptyValues.put(ExifInterface.TAG_APERTURE, "0"); //rational64u
emptyValues.put(ExifInterface.TAG_DATETIME, ""); //string
emptyValues.put(ExifInterface.TAG_EXPOSURE_TIME, "0.0000" ); //rational64u
emptyValues.put(ExifInterface.TAG_FLASH, "0" ); //int16u
emptyValues.put(ExifInterface.TAG_FOCAL_LENGTH, " 0/0" ); //rational64u
emptyValues.put(ExifInterface.TAG_GPS_ALTITUDE, "0/0" ); //rational64u
emptyValues.put(ExifInterface.TAG_GPS_ALTITUDE_REF, "0" ); //string[2]
emptyValues.put(ExifInterface.TAG_GPS_LATITUDE, "0/0,0/0000,00000000/00000" ); // rational64u
emptyValues.put(ExifInterface.TAG_GPS_LATITUDE_REF, "0" ); //string[2]
emptyValues.put(ExifInterface.TAG_GPS_LONGITUDE, "0/0,0/0,000000/00000 " ); //rational64u
emptyValues.put(ExifInterface.TAG_GPS_LONGITUDE_REF, "0" ); //sting[2]
emptyValues.put(ExifInterface.TAG_GPS_TIMESTAMP, "0:0:0 " ); //rational64u[3]
emptyValues.put(ExifInterface.TAG_GPS_PROCESSING_METHOD, "0" ); //undef
emptyValues.put(ExifInterface.TAG_GPS_DATESTAMP, " " ); //string[11]
emptyValues.put(ExifInterface.TAG_IMAGE_LENGTH, "0" ); //int32u
emptyValues.put(ExifInterface.TAG_IMAGE_WIDTH, "0" ); //int32u
emptyValues.put(ExifInterface.TAG_ISO, " " ); //int16u
emptyValues.put(ExifInterface.TAG_MAKE, " " ); //string
emptyValues.put(ExifInterface.TAG_MODEL, " " ); //string
emptyValues.put(ExifInterface.TAG_WHITE_BALANCE, " " ); //string
emptyValues.put(ExifInterface.TAG_ORIENTATION, " " ); // int16u
}
Is this a good approach? Is there a smarter way?
source to share
Is it possible to just load the image into an Android bitmap and then save the Bitmap to a new file? Bitmap objects do not store EXIF ββdata, so this will delete EXIF ββdata. The disadvantage of this method is, of course, that you have to compress it again and you may lose a little image quality.
source to share