Wednesday, November 23, 2011

Android ExifInterface (EXIF) Information

EXIF (Exchangeable Image File Format) is a specification for image file formats to store different metadata information.

ExifInterface class is used to retreive rotation information and etc.
But it only supports: JPEG, TIFF, RIFF, WAV
It does not support: GIF, PNG


On Android 2.0+, you can get & set following attributes:

ExifInterface.TAG_DATETIME
ExifInterface.TAG_FLASH
ExifInterface.TAG_FOCAL_LENGTH
ExifInterface.TAG_GPS_DATESTAMP
ExifInterface.TAG_GPS_LATITUDE
ExifInterface.TAG_GPS_LATITUDE_REF
ExifInterface.TAG_GPS_LONGITUDE
ExifInterface.TAG_GPS_LONGITUDE_REF
ExifInterface.TAG_GPS_PROCESSING_METHOD
ExifInterface.TAG_GPS_TIMESTAMP
ExifInterface.TAG_IMAGE_LENGTH
ExifInterface.TAG_IMAGE_WIDTH
ExifInterface.TAG_MAKE
ExifInterface.TAG_MODEL
ExifInterface.TAG_ORIENTATION
ExifInterface.TAG_WHITE_BALANCE

example:


             ExifInterface exif = null;
             try {
                    exif = new ExifInterface(filepath);
                    if (exif != null) {
                           exif.setAttribute(ExifInterface.TAG_ORIENTATION,
                                        Integer.toString(ExifInterface.ORIENTATION_ROTATE_90));
                           exif.saveAttributes();
                    }
             } catch (IOException ex) {
               
             }