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_DATETIME
String TAG_FLASH
String TAG_GPS_LATITUDE
String TAG_GPS_LATITUDE_REF
String TAG_GPS_LONGITUDE
String TAG_GPS_LONGITUDE_REF
String TAG_IMAGE_LENGTH
String TAG_IMAGE_WIDTH
String TAG_MAKE
String TAG_MODEL
String TAG_ORIENTATION
String TAG_WHITE_BALANCE
int WHITEBALANCE_AUTO
int WHITEBALANCE_MANUAL
Public Constructors
ExifInterface(String filename)
Reads Exif tags from the specified JPEG file.
Public Methods
String getAttribute(String tag)
Returns the value of the specified tag or null if there is no such tag in the JPEG file.
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_DATETIME

Since: API Level 5

Constant Value: "DateTime"

public static final String TAG_FLASH

Since: API Level 5

Constant Value: "Flash"

public static final String TAG_GPS_LATITUDE

Since: API Level 5

Constant Value: "GPSLatitude"

public static final String TAG_GPS_LATITUDE_REF

Since: API Level 5

Constant Value: "GPSLatitudeRef"

public static final String TAG_GPS_LONGITUDE

Since: API Level 5

Constant Value: "GPSLongitude"

public static final String TAG_GPS_LONGITUDE_REF

Since: API Level 5

Constant Value: "GPSLongitudeRef"

public static final String TAG_IMAGE_LENGTH

Since: API Level 5

Constant Value: "ImageLength"

public static final String TAG_IMAGE_WIDTH

Since: API Level 5

Constant Value: "ImageWidth"

public static final String TAG_MAKE

Since: API Level 5

Constant Value: "Make"

public static final String TAG_MODEL

Since: API Level 5

Constant Value: "Model"

public static final String TAG_ORIENTATION

Since: API Level 5

Constant Value: "Orientation"

public static final String TAG_WHITE_BALANCE

Since: API Level 5

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 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 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.