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 or a RAW image file.
Supported formats are: JPEG, DNG, CR2, NEF, NRW, ARW, RW2, ORF and RAF.
Attribute mutation is supported for JPEG image files.
Public constructors | |
---|---|
ExifInterface(String filename)
Reads Exif tags from the specified image file. |
|
ExifInterface(FileDescriptor fileDescriptor)
Reads Exif tags from the specified image file descriptor. |
|
ExifInterface(InputStream inputStream)
Reads Exif tags from the specified image input stream. |
Public methods | |
---|---|
double
|
getAltitude(double defaultValue)
Return the altitude in meters. |
String
|
getAttribute(String tag)
Returns the value of the specified tag or |
double
|
getAttributeDouble(String tag, double defaultValue)
Returns the double value of the tag that is specified as rational or contains a double-formatted value. |
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 image file, or |
long[]
|
getThumbnailRange()
Returns the offset and length of thumbnail inside the image file, or
|
boolean
|
hasThumbnail()
Returns true if the image file has a thumbnail. |
void
|
saveAttributes()
Save the tag data into the original image file. |
void
|
setAttribute(String tag, String value)
Set the value of the specified tag. |
Inherited methods | |
---|---|
From
class
java.lang.Object
|
int ORIENTATION_FLIP_HORIZONTAL
Constant Value: 2 (0x00000002)
int ORIENTATION_FLIP_VERTICAL
Constant Value: 4 (0x00000004)
int ORIENTATION_ROTATE_180
Constant Value: 3 (0x00000003)
int ORIENTATION_ROTATE_270
Constant Value: 8 (0x00000008)
int ORIENTATION_TRANSVERSE
Constant Value: 7 (0x00000007)
String TAG_APERTURE
This constant was deprecated
in API level 24.
use TAG_F_NUMBER
instead
Type is double.
Constant Value: "FNumber"
String TAG_APERTURE_VALUE
Type is rational.
Constant Value: "ApertureValue"
String TAG_BITS_PER_SAMPLE
Type is int.
Constant Value: "BitsPerSample"
String TAG_BRIGHTNESS_VALUE
Type is rational.
Constant Value: "BrightnessValue"
String TAG_CFA_PATTERN
Type is String.
Constant Value: "CFAPattern"
String TAG_COLOR_SPACE
Type is int.
Constant Value: "ColorSpace"
String TAG_COMPONENTS_CONFIGURATION
Type is String.
Constant Value: "ComponentsConfiguration"
String TAG_COMPRESSED_BITS_PER_PIXEL
Type is rational.
Constant Value: "CompressedBitsPerPixel"
String TAG_COMPRESSION
Type is int.
Constant Value: "Compression"
String TAG_COPYRIGHT
Type is String.
Constant Value: "Copyright"
String TAG_CUSTOM_RENDERED
Type is int.
Constant Value: "CustomRendered"
String TAG_DATETIME_DIGITIZED
Type is String.
Constant Value: "DateTimeDigitized"
String TAG_DATETIME_ORIGINAL
Type is String.
Constant Value: "DateTimeOriginal"
String TAG_DEVICE_SETTING_DESCRIPTION
Type is String.
Constant Value: "DeviceSettingDescription"
String TAG_DIGITAL_ZOOM_RATIO
Type is double.
Constant Value: "DigitalZoomRatio"
String TAG_EXIF_VERSION
Type is String.
Constant Value: "ExifVersion"
String TAG_EXPOSURE_BIAS_VALUE
Type is double.
Constant Value: "ExposureBiasValue"
String TAG_EXPOSURE_INDEX
Type is rational.
Constant Value: "ExposureIndex"
String TAG_EXPOSURE_MODE
Type is int.
Constant Value: "ExposureMode"
String TAG_EXPOSURE_PROGRAM
Type is int.
Constant Value: "ExposureProgram"
String TAG_EXPOSURE_TIME
Type is double.
Constant Value: "ExposureTime"
String TAG_FILE_SOURCE
Type is String.
Constant Value: "FileSource"
String TAG_FLASHPIX_VERSION
Type is String.
Constant Value: "FlashpixVersion"
String TAG_FLASH_ENERGY
Type is rational.
Constant Value: "FlashEnergy"
String TAG_FOCAL_LENGTH
Type is rational.
Constant Value: "FocalLength"
String TAG_FOCAL_LENGTH_IN_35MM_FILM
Type is int.
Constant Value: "FocalLengthIn35mmFilm"
String TAG_FOCAL_PLANE_RESOLUTION_UNIT
Type is int.
Constant Value: "FocalPlaneResolutionUnit"
String TAG_FOCAL_PLANE_X_RESOLUTION
Type is rational.
Constant Value: "FocalPlaneXResolution"
String TAG_FOCAL_PLANE_Y_RESOLUTION
Type is rational.
Constant Value: "FocalPlaneYResolution"
String TAG_GAIN_CONTROL
Type is int.
Constant Value: "GainControl"
String TAG_GPS_ALTITUDE
The altitude (in meters) based on the reference in TAG_GPS_ALTITUDE_REF. Type is rational.
Constant Value: "GPSAltitude"
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"
String TAG_GPS_AREA_INFORMATION
Type is String.
Constant Value: "GPSAreaInformation"
String TAG_GPS_DATESTAMP
Type is String.
Constant Value: "GPSDateStamp"
String TAG_GPS_DEST_BEARING
Type is rational.
Constant Value: "GPSDestBearing"
String TAG_GPS_DEST_BEARING_REF
Type is String.
Constant Value: "GPSDestBearingRef"
String TAG_GPS_DEST_DISTANCE
Type is rational.
Constant Value: "GPSDestDistance"
String TAG_GPS_DEST_DISTANCE_REF
Type is String.
Constant Value: "GPSDestDistanceRef"
String TAG_GPS_DEST_LATITUDE
Type is rational.
Constant Value: "GPSDestLatitude"
String TAG_GPS_DEST_LATITUDE_REF
Type is String.
Constant Value: "GPSDestLatitudeRef"
String TAG_GPS_DEST_LONGITUDE
Type is rational.
Constant Value: "GPSDestLongitude"
String TAG_GPS_DEST_LONGITUDE_REF
Type is String.
Constant Value: "GPSDestLongitudeRef"
String TAG_GPS_DIFFERENTIAL
Type is int.
Constant Value: "GPSDifferential"
String TAG_GPS_IMG_DIRECTION
Type is rational.
Constant Value: "GPSImgDirection"
String TAG_GPS_IMG_DIRECTION_REF
Type is String.
Constant Value: "GPSImgDirectionRef"
String TAG_GPS_LATITUDE
Type is rational. Format is "num1/denom1,num2/denom2,num3/denom3".
Constant Value: "GPSLatitude"
String TAG_GPS_LATITUDE_REF
Type is String.
Constant Value: "GPSLatitudeRef"
String TAG_GPS_LONGITUDE
Type is rational. Format is "num1/denom1,num2/denom2,num3/denom3".
Constant Value: "GPSLongitude"
String TAG_GPS_LONGITUDE_REF
Type is String.
Constant Value: "GPSLongitudeRef"
String TAG_GPS_MAP_DATUM
Type is String.
Constant Value: "GPSMapDatum"
String TAG_GPS_MEASURE_MODE
Type is String.
Constant Value: "GPSMeasureMode"
String TAG_GPS_PROCESSING_METHOD
Type is String. Name of GPS processing method used for location finding.
Constant Value: "GPSProcessingMethod"
String TAG_GPS_SATELLITES
Type is String.
Constant Value: "GPSSatellites"
String TAG_GPS_SPEED
Type is rational.
Constant Value: "GPSSpeed"
String TAG_GPS_SPEED_REF
Type is String.
Constant Value: "GPSSpeedRef"
String TAG_GPS_STATUS
Type is String.
Constant Value: "GPSStatus"
String TAG_GPS_TIMESTAMP
Type is String. Format is "hh:mm:ss".
Constant Value: "GPSTimeStamp"
String TAG_GPS_TRACK
Type is rational.
Constant Value: "GPSTrack"
String TAG_GPS_TRACK_REF
Type is String.
Constant Value: "GPSTrackRef"
String TAG_GPS_VERSION_ID
Type is String.
Constant Value: "GPSVersionID"
String TAG_IMAGE_DESCRIPTION
Type is String.
Constant Value: "ImageDescription"
String TAG_IMAGE_LENGTH
Type is int.
Constant Value: "ImageLength"
String TAG_IMAGE_UNIQUE_ID
Type is String.
Constant Value: "ImageUniqueID"
String TAG_IMAGE_WIDTH
Type is int.
Constant Value: "ImageWidth"
String TAG_INTEROPERABILITY_INDEX
Type is String.
Constant Value: "InteroperabilityIndex"
String TAG_ISO
This constant was deprecated
in API level 24.
use TAG_ISO_SPEED_RATINGS
instead
Type is int.
Constant Value: "ISOSpeedRatings"
String TAG_ISO_SPEED_RATINGS
Type is int.
Constant Value: "ISOSpeedRatings"
String TAG_JPEG_INTERCHANGE_FORMAT
Type is int.
Constant Value: "JPEGInterchangeFormat"
String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH
Type is int.
Constant Value: "JPEGInterchangeFormatLength"
String TAG_LIGHT_SOURCE
Type is int.
Constant Value: "LightSource"
String TAG_MAKER_NOTE
Type is String.
Constant Value: "MakerNote"
String TAG_MAX_APERTURE_VALUE
Type is rational.
Constant Value: "MaxApertureValue"
String TAG_METERING_MODE
Type is int.
Constant Value: "MeteringMode"
String TAG_ORIENTATION
Type is int.
Constant Value: "Orientation"
String TAG_PHOTOMETRIC_INTERPRETATION
Type is int.
Constant Value: "PhotometricInterpretation"
String TAG_PIXEL_X_DIMENSION
Type is int.
Constant Value: "PixelXDimension"
String TAG_PIXEL_Y_DIMENSION
Type is int.
Constant Value: "PixelYDimension"
String TAG_PLANAR_CONFIGURATION
Type is int.
Constant Value: "PlanarConfiguration"
String TAG_PRIMARY_CHROMATICITIES
Type is rational.
Constant Value: "PrimaryChromaticities"
String TAG_REFERENCE_BLACK_WHITE
Type is rational.
Constant Value: "ReferenceBlackWhite"
String TAG_RELATED_SOUND_FILE
Type is String.
Constant Value: "RelatedSoundFile"
String TAG_RESOLUTION_UNIT
Type is int.
Constant Value: "ResolutionUnit"
String TAG_ROWS_PER_STRIP
Type is int.
Constant Value: "RowsPerStrip"
String TAG_SAMPLES_PER_PIXEL
Type is int.
Constant Value: "SamplesPerPixel"
String TAG_SATURATION
Type is int.
Constant Value: "Saturation"
String TAG_SCENE_CAPTURE_TYPE
Type is int.
Constant Value: "SceneCaptureType"
String TAG_SCENE_TYPE
Type is String.
Constant Value: "SceneType"
String TAG_SENSING_METHOD
Type is int.
Constant Value: "SensingMethod"
String TAG_SHUTTER_SPEED_VALUE
Type is rational.
Constant Value: "ShutterSpeedValue"
String TAG_SPATIAL_FREQUENCY_RESPONSE
Type is String.
Constant Value: "SpatialFrequencyResponse"
String TAG_SPECTRAL_SENSITIVITY
Type is String.
Constant Value: "SpectralSensitivity"
String TAG_STRIP_BYTE_COUNTS
Type is int.
Constant Value: "StripByteCounts"
String TAG_STRIP_OFFSETS
Type is int.
Constant Value: "StripOffsets"
String TAG_SUBJECT_AREA
Type is int.
Constant Value: "SubjectArea"
String TAG_SUBJECT_DISTANCE
Type is double.
Constant Value: "SubjectDistance"
String TAG_SUBJECT_DISTANCE_RANGE
Type is int.
Constant Value: "SubjectDistanceRange"
String TAG_SUBJECT_LOCATION
Type is int.
Constant Value: "SubjectLocation"
String TAG_SUBSEC_TIME
Type is String.
Constant Value: "SubSecTime"
String TAG_SUBSEC_TIME_DIG
This constant was deprecated
in API level 24.
use TAG_SUBSEC_TIME_DIGITIZED
instead
Type is String.
Constant Value: "SubSecTimeDigitized"
String TAG_SUBSEC_TIME_DIGITIZED
Type is String.
Constant Value: "SubSecTimeDigitized"
String TAG_SUBSEC_TIME_ORIG
This constant was deprecated
in API level 24.
use TAG_SUBSEC_TIME_ORIGINAL
instead
Type is String.
Constant Value: "SubSecTimeOriginal"
String TAG_SUBSEC_TIME_ORIGINAL
Type is String.
Constant Value: "SubSecTimeOriginal"
String TAG_THUMBNAIL_IMAGE_LENGTH
Type is int.
Constant Value: "ThumbnailImageLength"
String TAG_THUMBNAIL_IMAGE_WIDTH
Type is int.
Constant Value: "ThumbnailImageWidth"
String TAG_TRANSFER_FUNCTION
Type is int.
Constant Value: "TransferFunction"
String TAG_USER_COMMENT
Type is String.
Constant Value: "UserComment"
String TAG_WHITE_BALANCE
Type is int.
Constant Value: "WhiteBalance"
String TAG_WHITE_POINT
Type is rational.
Constant Value: "WhitePoint"
String TAG_X_RESOLUTION
Type is rational.
Constant Value: "XResolution"
String TAG_Y_CB_CR_COEFFICIENTS
Type is rational.
Constant Value: "YCbCrCoefficients"
String TAG_Y_CB_CR_POSITIONING
Type is int.
Constant Value: "YCbCrPositioning"
String TAG_Y_CB_CR_SUB_SAMPLING
Type is int.
Constant Value: "YCbCrSubSampling"
String TAG_Y_RESOLUTION
Type is rational.
Constant Value: "YResolution"
ExifInterface (String filename)
Reads Exif tags from the specified image file.
Parameters | |
---|---|
filename |
String
|
Throws | |
---|---|
IOException |
ExifInterface (FileDescriptor fileDescriptor)
Reads Exif tags from the specified image file descriptor. Attribute mutation is supported for writable and seekable file descriptors only. This constructor will not rewind the offset of the given file descriptor. Developers should close the file descriptor after use.
Parameters | |
---|---|
fileDescriptor |
FileDescriptor
|
Throws | |
---|---|
IOException |
ExifInterface (InputStream inputStream)
Reads Exif tags from the specified image input stream. Attribute mutation is not supported for input streams. The given input stream will proceed its current position. Developers should close the input stream after use.
Parameters | |
---|---|
inputStream |
InputStream
|
Throws | |
---|---|
IOException |
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 |
String getAttribute (String tag)
Returns the value of the specified tag or null
if there
is no such tag in the image file.
Parameters | |
---|---|
tag |
String :
the name of the tag.
|
Returns | |
---|---|
String |
double getAttributeDouble (String tag, double defaultValue)
Returns the double value of the tag that is specified as rational or contains a double-formatted value. If there is no such tag in the image 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 |
int getAttributeInt (String tag, int defaultValue)
Returns the integer value of the specified tag. If there is no such tag in the image 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 |
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 |
byte[] getThumbnail ()
Returns the thumbnail inside the image 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[] |
long[] getThumbnailRange ()
Returns the offset and length of thumbnail inside the image file, or
null
if there is no thumbnail.
Returns | |
---|---|
long[] |
two-element array, the offset in the first value, and length in
the second, or null if no thumbnail was found.
|
boolean hasThumbnail ()
Returns true if the image file has a thumbnail.
Returns | |
---|---|
boolean |
void saveAttributes ()
Save the tag data into the original image file. This is expensive because it involves
copying all the 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 |
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.
|