to top
Android APIs
public class

ExifInterface

extends Object
java.lang.Object
   ↳ android.media.ExifInterface

Class Overview

This is a class for reading and writing Exif tags in a JPEG file.

Summary

Constants
int ORIENTATION_FLIP_HORIZONTAL
int ORIENTATION_FLIP_VERTICAL
int ORIENTATION_NORMAL
int ORIENTATION_ROTATE_180
int ORIENTATION_ROTATE_270
int ORIENTATION_ROTATE_90
int ORIENTATION_TRANSPOSE
int ORIENTATION_TRANSVERSE
int ORIENTATION_UNDEFINED
String TAG_APERTURE Type is String.
String TAG_DATETIME Type is String.
String TAG_EXPOSURE_TIME Type is String.
String TAG_FLASH Type is int.
String TAG_FOCAL_LENGTH Type is rational.
String TAG_GPS_ALTITUDE The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF.
String TAG_GPS_ALTITUDE_REF 0 if the altitude is above sea level.
String TAG_GPS_DATESTAMP Type is String.
String TAG_GPS_LATITUDE String.
String TAG_GPS_LATITUDE_REF Type is String.
String TAG_GPS_LONGITUDE String.
String TAG_GPS_LONGITUDE_REF Type is String.
String TAG_GPS_PROCESSING_METHOD Type is String.
String TAG_GPS_TIMESTAMP Type is String.
String TAG_IMAGE_LENGTH Type is int.
String TAG_IMAGE_WIDTH Type is int.
String TAG_ISO Type is String.
String TAG_MAKE Type is String.
String TAG_MODEL Type is String.
String TAG_ORIENTATION Type is int.
String TAG_WHITE_BALANCE Type is int.
int WHITEBALANCE_AUTO
int WHITEBALANCE_MANUAL
Public Constructors
ExifInterface(String filename)
Reads Exif tags from the specified JPEG file.
Public Methods
double getAltitude(double defaultValue)
Return the altitude in meters.
String getAttribute(String tag)
Returns the value of the specified tag or null if there is no such tag in the JPEG file.
double getAttributeDouble(String tag, double defaultValue)
Returns the double value of the specified rational tag.
int getAttributeInt(String tag, int defaultValue)
Returns the integer value of the specified tag.
boolean getLatLong(float[] output)
Stores the latitude and longitude value in a float array.
byte[] getThumbnail()
Returns the thumbnail inside the JPEG file, or null if there is no thumbnail.
boolean hasThumbnail()
Returns true if the JPEG file has a thumbnail.
void saveAttributes()
Save the tag data into the JPEG file.
void setAttribute(String tag, String value)
Set the value of the specified tag.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int ORIENTATION_FLIP_HORIZONTAL

Since: API Level 5

Constant Value: 2 (0x00000002)

public static final int ORIENTATION_FLIP_VERTICAL

Since: API Level 5

Constant Value: 4 (0x00000004)

public static final int ORIENTATION_NORMAL

Since: API Level 5

Constant Value: 1 (0x00000001)

public static final int ORIENTATION_ROTATE_180

Since: API Level 5

Constant Value: 3 (0x00000003)

public static final int ORIENTATION_ROTATE_270

Since: API Level 5

Constant Value: 8 (0x00000008)

public static final int ORIENTATION_ROTATE_90

Since: API Level 5

Constant Value: 6 (0x00000006)

public static final int ORIENTATION_TRANSPOSE

Since: API Level 5

Constant Value: 5 (0x00000005)

public static final int ORIENTATION_TRANSVERSE

Since: API Level 5

Constant Value: 7 (0x00000007)

public static final int ORIENTATION_UNDEFINED

Since: API Level 5

Constant Value: 0 (0x00000000)

public static final String TAG_APERTURE

Since: API Level 11

Type is String.

Constant Value: "FNumber"

public static final String TAG_DATETIME

Since: API Level 5

Type is String.

Constant Value: "DateTime"

public static final String TAG_EXPOSURE_TIME

Since: API Level 11

Type is String.

Constant Value: "ExposureTime"

public static final String TAG_FLASH

Since: API Level 5

Type is int.

Constant Value: "Flash"

public static final String TAG_FOCAL_LENGTH

Since: API Level 8

Type is rational.

Constant Value: "FocalLength"

public static final String TAG_GPS_ALTITUDE

Since: API Level 9

The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF. Type is rational.

Constant Value: "GPSAltitude"

public static final String TAG_GPS_ALTITUDE_REF

Since: API Level 9

0 if the altitude is above sea level. 1 if the altitude is below sea level. Type is int.

Constant Value: "GPSAltitudeRef"

public static final String TAG_GPS_DATESTAMP

Since: API Level 8

Type is String.

Constant Value: "GPSDateStamp"

public static final String TAG_GPS_LATITUDE

Since: API Level 5

String. Format is "num1/denom1,num2/denom2,num3/denom3".

Constant Value: "GPSLatitude"

public static final String TAG_GPS_LATITUDE_REF

Since: API Level 5

Type is String.

Constant Value: "GPSLatitudeRef"

public static final String TAG_GPS_LONGITUDE

Since: API Level 5

String. Format is "num1/denom1,num2/denom2,num3/denom3".

Constant Value: "GPSLongitude"

public static final String TAG_GPS_LONGITUDE_REF

Since: API Level 5

Type is String.

Constant Value: "GPSLongitudeRef"

public static final String TAG_GPS_PROCESSING_METHOD

Since: API Level 8

Type is String. Name of GPS processing method used for location finding.

Constant Value: "GPSProcessingMethod"

public static final String TAG_GPS_TIMESTAMP

Since: API Level 8

Type is String.

Constant Value: "GPSTimeStamp"

public static final String TAG_IMAGE_LENGTH

Since: API Level 5

Type is int.

Constant Value: "ImageLength"

public static final String TAG_IMAGE_WIDTH

Since: API Level 5

Type is int.

Constant Value: "ImageWidth"

public static final String TAG_ISO

Since: API Level 11

Type is String.

Constant Value: "ISOSpeedRatings"

public static final String TAG_MAKE

Since: API Level 5

Type is String.

Constant Value: "Make"

public static final String TAG_MODEL

Since: API Level 5

Type is String.

Constant Value: "Model"

public static final String TAG_ORIENTATION

Since: API Level 5

Type is int.

Constant Value: "Orientation"

public static final String TAG_WHITE_BALANCE

Since: API Level 5

Type is int.

Constant Value: "WhiteBalance"

public static final int WHITEBALANCE_AUTO

Since: API Level 5

Constant Value: 0 (0x00000000)

public static final int WHITEBALANCE_MANUAL

Since: API Level 5

Constant Value: 1 (0x00000001)

Public Constructors

public ExifInterface (String filename)

Since: API Level 5

Reads Exif tags from the specified JPEG file.

Throws
IOException

Public Methods

public double getAltitude (double defaultValue)

Since: API Level 9

Return the altitude in meters. If the exif tag does not exist, return defaultValue.

Parameters
defaultValue the value to return if the tag is not available.

public String getAttribute (String tag)

Since: API Level 5

Returns the value of the specified tag or null if there is no such tag in the JPEG file.

Parameters
tag the name of the tag.

public double getAttributeDouble (String tag, double defaultValue)

Since: API Level 8

Returns the double value of the specified rational tag. If there is no such tag in the JPEG file or the value cannot be parsed as double, return defaultValue.

Parameters
tag the name of the tag.
defaultValue the value to return if the tag is not available.

public int getAttributeInt (String tag, int defaultValue)

Since: API Level 5

Returns the integer value of the specified tag. If there is no such tag in the JPEG file or the value cannot be parsed as integer, return defaultValue.

Parameters
tag the name of the tag.
defaultValue the value to return if the tag is not available.

public boolean getLatLong (float[] output)

Since: API Level 5

Stores the latitude and longitude value in a float array. The first element is the latitude, and the second element is the longitude. Returns false if the Exif tags are not available.

public byte[] getThumbnail ()

Since: API Level 5

Returns the thumbnail inside the JPEG file, or null if there is no thumbnail. The returned data is in JPEG format and can be decoded using decodeByteArray(byte[], int, int)

public boolean hasThumbnail ()

Since: API Level 5

Returns true if the JPEG file has a thumbnail.

public void saveAttributes ()

Since: API Level 5

Save the tag data into the JPEG file. This is expensive because it involves copying all the JPG data from one file to another and deleting the old file and renaming the other. It's best to use setAttribute(String, String) to set all attributes to write and make a single call rather than multiple calls for each attribute.

Throws
IOException

public void setAttribute (String tag, String value)

Since: API Level 5

Set the value of the specified tag.

Parameters
tag the name of the tag.
value the value of the tag.