Skip to content

Most visited

Recently visited

navigation
Added in API level 5

ExifInterface

public class ExifInterface
extends Object

java.lang.Object
   ↳ android.media.ExifInterface


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_DATETIME_DIGITIZED

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_SUBSEC_TIME

Type is int.

String TAG_SUBSEC_TIME_DIG

Type is int.

String TAG_SUBSEC_TIME_ORIG

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.

Inherited methods

From class java.lang.Object

Constants

ORIENTATION_FLIP_HORIZONTAL

Added in API level 5
int ORIENTATION_FLIP_HORIZONTAL

Constant Value: 2 (0x00000002)

ORIENTATION_FLIP_VERTICAL

Added in API level 5
int ORIENTATION_FLIP_VERTICAL

Constant Value: 4 (0x00000004)

ORIENTATION_NORMAL

Added in API level 5
int ORIENTATION_NORMAL

Constant Value: 1 (0x00000001)

ORIENTATION_ROTATE_180

Added in API level 5
int ORIENTATION_ROTATE_180

Constant Value: 3 (0x00000003)

ORIENTATION_ROTATE_270

Added in API level 5
int ORIENTATION_ROTATE_270

Constant Value: 8 (0x00000008)

ORIENTATION_ROTATE_90

Added in API level 5
int ORIENTATION_ROTATE_90

Constant Value: 6 (0x00000006)

ORIENTATION_TRANSPOSE

Added in API level 5
int ORIENTATION_TRANSPOSE

Constant Value: 5 (0x00000005)

ORIENTATION_TRANSVERSE

Added in API level 5
int ORIENTATION_TRANSVERSE

Constant Value: 7 (0x00000007)

ORIENTATION_UNDEFINED

Added in API level 5
int ORIENTATION_UNDEFINED

Constant Value: 0 (0x00000000)

TAG_APERTURE

Added in API level 11
String TAG_APERTURE

Type is String.

Constant Value: "FNumber"

TAG_DATETIME

Added in API level 5
String TAG_DATETIME

Type is String.

Constant Value: "DateTime"

TAG_DATETIME_DIGITIZED

Added in API level 23
String TAG_DATETIME_DIGITIZED

Type is String.

Constant Value: "DateTimeDigitized"

TAG_EXPOSURE_TIME

Added in API level 11
String TAG_EXPOSURE_TIME

Type is String.

Constant Value: "ExposureTime"

TAG_FLASH

Added in API level 5
String TAG_FLASH

Type is int.

Constant Value: "Flash"

TAG_FOCAL_LENGTH

Added in API level 8
String TAG_FOCAL_LENGTH

Type is rational.

Constant Value: "FocalLength"

TAG_GPS_ALTITUDE

Added in API level 9
String TAG_GPS_ALTITUDE

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

Constant Value: "GPSAltitude"

TAG_GPS_ALTITUDE_REF

Added in API level 9
String TAG_GPS_ALTITUDE_REF

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

Constant Value: "GPSAltitudeRef"

TAG_GPS_DATESTAMP

Added in API level 8
String TAG_GPS_DATESTAMP

Type is String.

Constant Value: "GPSDateStamp"

TAG_GPS_LATITUDE

Added in API level 5
String TAG_GPS_LATITUDE

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

Constant Value: "GPSLatitude"

TAG_GPS_LATITUDE_REF

Added in API level 5
String TAG_GPS_LATITUDE_REF

Type is String.

Constant Value: "GPSLatitudeRef"

TAG_GPS_LONGITUDE

Added in API level 5
String TAG_GPS_LONGITUDE

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

Constant Value: "GPSLongitude"

TAG_GPS_LONGITUDE_REF

Added in API level 5
String TAG_GPS_LONGITUDE_REF

Type is String.

Constant Value: "GPSLongitudeRef"

TAG_GPS_PROCESSING_METHOD

Added in API level 8
String TAG_GPS_PROCESSING_METHOD

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

Constant Value: "GPSProcessingMethod"

TAG_GPS_TIMESTAMP

Added in API level 8
String TAG_GPS_TIMESTAMP

Type is String.

Constant Value: "GPSTimeStamp"

TAG_IMAGE_LENGTH

Added in API level 5
String TAG_IMAGE_LENGTH

Type is int.

Constant Value: "ImageLength"

TAG_IMAGE_WIDTH

Added in API level 5
String TAG_IMAGE_WIDTH

Type is int.

Constant Value: "ImageWidth"

TAG_ISO

Added in API level 11
String TAG_ISO

Type is String.

Constant Value: "ISOSpeedRatings"

TAG_MAKE

Added in API level 5
String TAG_MAKE

Type is String.

Constant Value: "Make"

TAG_MODEL

Added in API level 5
String TAG_MODEL

Type is String.

Constant Value: "Model"

TAG_ORIENTATION

Added in API level 5
String TAG_ORIENTATION

Type is int.

Constant Value: "Orientation"

TAG_SUBSEC_TIME

Added in API level 23
String TAG_SUBSEC_TIME

Type is int.

Constant Value: "SubSecTime"

TAG_SUBSEC_TIME_DIG

Added in API level 23
String TAG_SUBSEC_TIME_DIG

Type is int.

Constant Value: "SubSecTimeDigitized"

TAG_SUBSEC_TIME_ORIG

Added in API level 23
String TAG_SUBSEC_TIME_ORIG

Type is int.

Constant Value: "SubSecTimeOriginal"

TAG_WHITE_BALANCE

Added in API level 5
String TAG_WHITE_BALANCE

Type is int.

Constant Value: "WhiteBalance"

WHITEBALANCE_AUTO

Added in API level 5
int WHITEBALANCE_AUTO

Constant Value: 0 (0x00000000)

WHITEBALANCE_MANUAL

Added in API level 5
int WHITEBALANCE_MANUAL

Constant Value: 1 (0x00000001)

Public constructors

ExifInterface

Added in API level 5
ExifInterface (String filename)

Reads Exif tags from the specified JPEG file.

Parameters
filename String
Throws
IOException

Public methods

getAltitude

Added in API level 9
double getAltitude (double defaultValue)

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

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

getAttribute

Added in API level 5
String getAttribute (String tag)

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

Parameters
tag String: the name of the tag.
Returns
String

getAttributeDouble

Added in API level 8
double getAttributeDouble (String tag, 
                double defaultValue)

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 String: the name of the tag.
defaultValue double: the value to return if the tag is not available.
Returns
double

getAttributeInt

Added in API level 5
int getAttributeInt (String tag, 
                int defaultValue)

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 String: the name of the tag.
defaultValue int: the value to return if the tag is not available.
Returns
int

getLatLong

Added in API level 5
boolean getLatLong (float[] output)

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.

Parameters
output float
Returns
boolean

getThumbnail

Added in API level 5
byte[] getThumbnail ()

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)

Returns
byte[]

hasThumbnail

Added in API level 5
boolean hasThumbnail ()

Returns true if the JPEG file has a thumbnail.

Returns
boolean

saveAttributes

Added in API level 5
void saveAttributes ()

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

setAttribute

Added in API level 5
void setAttribute (String tag, 
                String value)

Set the value of the specified tag.

Parameters
tag String: the name of the tag.
value String: the value of the tag.
This site uses cookies to store your preferences for site-specific language and display options.

Hooray!

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.