# Print output for @column tags ?>
public
class
ExifInterface
extends Object
java.lang.Object | |
↳ | android.media.ExifInterface |
This is a class for reading and writing Exif tags in various image file formats.
Supported for reading: JPEG, PNG, WebP, HEIF, DNG, CR2, NEF, NRW, ARW, RW2, ORF, PEF, SRW, RAF, AVIF.
Supported for writing: JPEG, PNG, WebP.
Note: JPEG and HEIF files may contain XMP data either inside the Exif data chunk or outside of it. This class will search both locations for XMP data, but if XMP data exist both inside and outside Exif, will favor the XMP data inside Exif over the one outside.
Note: It is recommended to use the AndroidX ExifInterface Library since it is a superset of this class. In addition to the functionalities of this class, it supports parsing extra metadata such as exposure and data compression information as well as setting extra metadata such as GPS and datetime information.
Public constructors | |
---|---|
ExifInterface(File file)
Reads Exif tags from the specified image file. |
|
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. |
|
ExifInterface(InputStream inputStream, int streamType)
Reads Exif tags from the specified image input stream based on the stream type. |
Public methods | |
---|---|
double
|
getAltitude(double defaultValue)
Return the altitude in meters. |
String
|
getAttribute(String tag)
Returns the value of the specified tag or |
byte[]
|
getAttributeBytes(String tag)
Returns the raw bytes for the value of the requested tag inside the image
file, 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. |
long[]
|
getAttributeRange(String tag)
Returns the offset and length of the requested tag inside the image file,
or |
long
|
getDateTime()
Returns parsed |
long
|
getDateTimeDigitized()
Returns parsed |
long
|
getDateTimeOriginal()
Returns parsed |
long
|
getGpsDateTime()
Returns number of milliseconds since Jan. |
boolean
|
getLatLong(float[] output)
Stores the latitude and longitude value in a float array. |
byte[]
|
getThumbnail()
Returns the JPEG compressed thumbnail inside the image file, or |
Bitmap
|
getThumbnailBitmap()
Creates and returns a Bitmap object of the thumbnail image based on the byte array and the
thumbnail compression value, or |
byte[]
|
getThumbnailBytes()
Returns the thumbnail bytes inside the image file, regardless of the compression type of the thumbnail image. |
long[]
|
getThumbnailRange()
Returns the offset and length of thumbnail inside the image file, or
|
boolean
|
hasAttribute(String tag)
Returns true if the image file has the given attribute defined. |
boolean
|
hasThumbnail()
Returns true if the image file has a thumbnail. |
static
boolean
|
isSupportedMimeType(String mimeType)
Returns whether ExifInterface currently supports reading data from the specified mime type or not. |
boolean
|
isThumbnailCompressed()
Returns true if thumbnail image is JPEG Compressed, or false if either thumbnail image does not exist or thumbnail image is uncompressed. |
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 | |
---|---|
public static final int ORIENTATION_FLIP_HORIZONTAL
Constant Value: 2 (0x00000002)
public static final int ORIENTATION_FLIP_VERTICAL
Constant Value: 4 (0x00000004)
public static final int ORIENTATION_NORMAL
Constant Value: 1 (0x00000001)
public static final int ORIENTATION_ROTATE_180
Constant Value: 3 (0x00000003)
public static final int ORIENTATION_ROTATE_270
Constant Value: 8 (0x00000008)
public static final int ORIENTATION_ROTATE_90
Constant Value: 6 (0x00000006)
public static final int ORIENTATION_TRANSPOSE
Constant Value: 5 (0x00000005)
public static final int ORIENTATION_TRANSVERSE
Constant Value: 7 (0x00000007)
public static final int ORIENTATION_UNDEFINED
Constant Value: 0 (0x00000000)
public static final int STREAM_TYPE_EXIF_DATA_ONLY
Constant used to indicate that the input stream contains only Exif data.
The format of the Exif-only data must follow the below structure: Exif Identifier Code ("Exif\0\0") + TIFF header + IFD data See JEITA CP-3451C Section 4.5.2 and 4.5.4 specifications for more details.
Constant Value: 1 (0x00000001)
public static final int STREAM_TYPE_FULL_IMAGE_DATA
Constant used to indicate that the input stream contains the full image data.
The format of the image data should follow one of the image formats supported by this class.
Constant Value: 0 (0x00000000)
public static final String TAG_APERTURE
This constant is deprecated.
use TAG_F_NUMBER
instead
Type is double.
Constant Value: "FNumber"
public static final String TAG_APERTURE_VALUE
Type is rational.
Constant Value: "ApertureValue"
public static final String TAG_BITS_PER_SAMPLE
Type is int.
Constant Value: "BitsPerSample"
public static final String TAG_BRIGHTNESS_VALUE
Type is rational.
Constant Value: "BrightnessValue"
public static final String TAG_CFA_PATTERN
Type is String.
Constant Value: "CFAPattern"
public static final String TAG_COLOR_SPACE
Type is int.
Constant Value: "ColorSpace"
public static final String TAG_COMPONENTS_CONFIGURATION
Type is String.
Constant Value: "ComponentsConfiguration"
public static final String TAG_COMPRESSED_BITS_PER_PIXEL
Type is rational.
Constant Value: "CompressedBitsPerPixel"
public static final String TAG_COMPRESSION
Type is int.
Constant Value: "Compression"
public static final String TAG_CUSTOM_RENDERED
Type is int.
Constant Value: "CustomRendered"
public static final String TAG_DATETIME_DIGITIZED
Type is String.
Constant Value: "DateTimeDigitized"
public static final String TAG_DATETIME_ORIGINAL
Type is String.
Constant Value: "DateTimeOriginal"
public static final String TAG_DEFAULT_CROP_SIZE
Type is int. DNG Specification 1.4.0.0. Section 4
Constant Value: "DefaultCropSize"
public static final String TAG_DEVICE_SETTING_DESCRIPTION
Type is String.
Constant Value: "DeviceSettingDescription"
public static final String TAG_DIGITAL_ZOOM_RATIO
Type is double.
Constant Value: "DigitalZoomRatio"
public static final String TAG_DNG_VERSION
Type is int. DNG Specification 1.4.0.0. Section 4
Constant Value: "DNGVersion"
public static final String TAG_EXIF_VERSION
Type is String.
Constant Value: "ExifVersion"
public static final String TAG_EXPOSURE_BIAS_VALUE
Type is double.
Constant Value: "ExposureBiasValue"
public static final String TAG_EXPOSURE_INDEX
Type is rational.
Constant Value: "ExposureIndex"
public static final String TAG_EXPOSURE_MODE
Type is int.
Constant Value: "ExposureMode"
public static final String TAG_EXPOSURE_PROGRAM
Type is int.
Constant Value: "ExposureProgram"
public static final String TAG_EXPOSURE_TIME
Type is double.
Constant Value: "ExposureTime"
public static final String TAG_FILE_SOURCE
Type is String.
Constant Value: "FileSource"
public static final String TAG_FLASHPIX_VERSION
Type is String.
Constant Value: "FlashpixVersion"
public static final String TAG_FLASH_ENERGY
Type is rational.
Constant Value: "FlashEnergy"
public static final String TAG_FOCAL_LENGTH
Type is rational.
Constant Value: "FocalLength"
public static final String TAG_FOCAL_LENGTH_IN_35MM_FILM
Type is int.
Constant Value: "FocalLengthIn35mmFilm"
public static final String TAG_FOCAL_PLANE_RESOLUTION_UNIT
Type is int.
Constant Value: "FocalPlaneResolutionUnit"
public static final String TAG_FOCAL_PLANE_X_RESOLUTION
Type is rational.
Constant Value: "FocalPlaneXResolution"
public static final String TAG_FOCAL_PLANE_Y_RESOLUTION
Type is rational.
Constant Value: "FocalPlaneYResolution"
public static final String TAG_GAIN_CONTROL
Type is int.
Constant Value: "GainControl"
public static final String TAG_GPS_ALTITUDE
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
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_AREA_INFORMATION
Type is String.
Constant Value: "GPSAreaInformation"
public static final String TAG_GPS_DATESTAMP
Type is String.
Constant Value: "GPSDateStamp"
public static final String TAG_GPS_DEST_BEARING
Type is rational.
Constant Value: "GPSDestBearing"
public static final String TAG_GPS_DEST_BEARING_REF
Type is String.
Constant Value: "GPSDestBearingRef"
public static final String TAG_GPS_DEST_DISTANCE
Type is rational.
Constant Value: "GPSDestDistance"
public static final String TAG_GPS_DEST_DISTANCE_REF
Type is String.
Constant Value: "GPSDestDistanceRef"
public static final String TAG_GPS_DEST_LATITUDE
Type is rational.
Constant Value: "GPSDestLatitude"
public static final String TAG_GPS_DEST_LATITUDE_REF
Type is String.
Constant Value: "GPSDestLatitudeRef"
public static final String TAG_GPS_DEST_LONGITUDE
Type is rational.
Constant Value: "GPSDestLongitude"
public static final String TAG_GPS_DEST_LONGITUDE_REF
Type is String.
Constant Value: "GPSDestLongitudeRef"
public static final String TAG_GPS_DIFFERENTIAL
Type is int.
Constant Value: "GPSDifferential"
public static final String TAG_GPS_IMG_DIRECTION
Type is rational.
Constant Value: "GPSImgDirection"
public static final String TAG_GPS_IMG_DIRECTION_REF
Type is String.
Constant Value: "GPSImgDirectionRef"
public static final String TAG_GPS_LATITUDE
Type is rational. Format is "num1/denom1,num2/denom2,num3/denom3".
Constant Value: "GPSLatitude"
public static final String TAG_GPS_LATITUDE_REF
Type is String.
Constant Value: "GPSLatitudeRef"
public static final String TAG_GPS_LONGITUDE
Type is rational. Format is "num1/denom1,num2/denom2,num3/denom3".
Constant Value: "GPSLongitude"
public static final String TAG_GPS_LONGITUDE_REF
Type is String.
Constant Value: "GPSLongitudeRef"
public static final String TAG_GPS_MAP_DATUM
Type is String.
Constant Value: "GPSMapDatum"
public static final String TAG_GPS_MEASURE_MODE
Type is String.
Constant Value: "GPSMeasureMode"
public static final String TAG_GPS_PROCESSING_METHOD
Type is String. Name of GPS processing method used for location finding.
Constant Value: "GPSProcessingMethod"
public static final String TAG_GPS_SATELLITES
Type is String.
Constant Value: "GPSSatellites"
public static final String TAG_GPS_SPEED_REF
Type is String.
Constant Value: "GPSSpeedRef"
public static final String TAG_GPS_STATUS
Type is String.
Constant Value: "GPSStatus"
public static final String TAG_GPS_TIMESTAMP
Type is String. Format is "hh:mm:ss".
Constant Value: "GPSTimeStamp"
public static final String TAG_GPS_TRACK_REF
Type is String.
Constant Value: "GPSTrackRef"
public static final String TAG_GPS_VERSION_ID
Type is String.
Constant Value: "GPSVersionID"
public static final String TAG_IMAGE_DESCRIPTION
Type is String.
Constant Value: "ImageDescription"
public static final String TAG_IMAGE_LENGTH
Type is int.
Constant Value: "ImageLength"
public static final String TAG_IMAGE_UNIQUE_ID
Type is String.
Constant Value: "ImageUniqueID"
public static final String TAG_IMAGE_WIDTH
Type is int.
Constant Value: "ImageWidth"
public static final String TAG_INTEROPERABILITY_INDEX
Type is String.
Constant Value: "InteroperabilityIndex"
public static final String TAG_ISO
This constant is deprecated.
use TAG_ISO_SPEED_RATINGS
instead
Type is int.
Constant Value: "ISOSpeedRatings"
public static final String TAG_ISO_SPEED_RATINGS
Type is int.
Constant Value: "ISOSpeedRatings"
public static final String TAG_JPEG_INTERCHANGE_FORMAT
Type is int.
Constant Value: "JPEGInterchangeFormat"
public static final String TAG_JPEG_INTERCHANGE_FORMAT_LENGTH
Type is int.
Constant Value: "JPEGInterchangeFormatLength"
public static final String TAG_LIGHT_SOURCE
Type is int.
Constant Value: "LightSource"
public static final String TAG_MAKER_NOTE
Type is String.
Constant Value: "MakerNote"
public static final String TAG_MAX_APERTURE_VALUE
Type is rational.
Constant Value: "MaxApertureValue"
public static final String TAG_METERING_MODE
Type is int.
Constant Value: "MeteringMode"
public static final String TAG_NEW_SUBFILE_TYPE
Type is int.
Constant Value: "NewSubfileType"
public static final String TAG_OFFSET_TIME
A tag used to record the offset from UTC (the time difference from Universal Time Coordinated including daylight saving time) of the time of DateTime tag. The format when recording the offset is "±HH:MM". The part of "±" shall be recorded as "+" or "-". When the offsets are unknown, all the character spaces except colons (":") should be filled with blank characters, or else the Interoperability field should be filled with blank characters. The character string length is 7 Bytes including NULL for termination. When the field is left blank, it is treated as unknown.
Constant Value: "OffsetTime"
public static final String TAG_OFFSET_TIME_DIGITIZED
A tag used to record the offset from UTC (the time difference from Universal Time Coordinated including daylight saving time) of the time of DateTimeDigitized tag. The format when recording the offset is "±HH:MM". The part of "±" shall be recorded as "+" or "-". When the offsets are unknown, all the character spaces except colons (":") should be filled with blank characters, or else the Interoperability field should be filled with blank characters. The character string length is 7 Bytes including NULL for termination. When the field is left blank, it is treated as unknown.
Constant Value: "OffsetTimeDigitized"
public static final String TAG_OFFSET_TIME_ORIGINAL
A tag used to record the offset from UTC (the time difference from Universal Time Coordinated including daylight saving time) of the time of DateTimeOriginal tag. The format when recording the offset is "±HH:MM". The part of "±" shall be recorded as "+" or "-". When the offsets are unknown, all the character spaces except colons (":") should be filled with blank characters, or else the Interoperability field should be filled with blank characters. The character string length is 7 Bytes including NULL for termination. When the field is left blank, it is treated as unknown.
Constant Value: "OffsetTimeOriginal"
public static final String TAG_ORF_ASPECT_FRAME
Type is int. See Olympus Image Processing tags in http://www.exiv2.org/tags-olympus.html.
Constant Value: "AspectFrame"
public static final String TAG_ORF_PREVIEW_IMAGE_LENGTH
Type is int. See Olympus Camera Settings tags in http://www.exiv2.org/tags-olympus.html.
Constant Value: "PreviewImageLength"
public static final String TAG_ORF_PREVIEW_IMAGE_START
Type is int. See Olympus Camera Settings tags in http://www.exiv2.org/tags-olympus.html.
Constant Value: "PreviewImageStart"
public static final String TAG_ORF_THUMBNAIL_IMAGE
Type is undefined. See Olympus MakerNote tags in http://www.exiv2.org/tags-olympus.html.
Constant Value: "ThumbnailImage"
public static final String TAG_ORIENTATION
Type is int.
Constant Value: "Orientation"
public static final String TAG_PHOTOMETRIC_INTERPRETATION
Type is int.
Constant Value: "PhotometricInterpretation"
public static final String TAG_PIXEL_X_DIMENSION
Type is int.
Constant Value: "PixelXDimension"
public static final String TAG_PIXEL_Y_DIMENSION
Type is int.
Constant Value: "PixelYDimension"
public static final String TAG_PLANAR_CONFIGURATION
Type is int.
Constant Value: "PlanarConfiguration"
public static final String TAG_PRIMARY_CHROMATICITIES
Type is rational.
Constant Value: "PrimaryChromaticities"
public static final String TAG_REFERENCE_BLACK_WHITE
Type is rational.
Constant Value: "ReferenceBlackWhite"
public static final String TAG_RELATED_SOUND_FILE
Type is String.
Constant Value: "RelatedSoundFile"
public static final String TAG_RESOLUTION_UNIT
Type is int.
Constant Value: "ResolutionUnit"
public static final String TAG_ROWS_PER_STRIP
Type is int.
Constant Value: "RowsPerStrip"
public static final String TAG_RW2_ISO
Type is int. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "ISO"
public static final String TAG_RW2_JPG_FROM_RAW
Type is undefined. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "JpgFromRaw"
public static final String TAG_RW2_SENSOR_BOTTOM_BORDER
Type is int. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "SensorBottomBorder"
public static final String TAG_RW2_SENSOR_LEFT_BORDER
Type is int. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "SensorLeftBorder"
public static final String TAG_RW2_SENSOR_RIGHT_BORDER
Type is int. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "SensorRightBorder"
public static final String TAG_RW2_SENSOR_TOP_BORDER
Type is int. See PanasonicRaw tags in http://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/PanasonicRaw.html
Constant Value: "SensorTopBorder"
public static final String TAG_SAMPLES_PER_PIXEL
Type is int.
Constant Value: "SamplesPerPixel"
public static final String TAG_SCENE_CAPTURE_TYPE
Type is int.
Constant Value: "SceneCaptureType"
public static final String TAG_SCENE_TYPE
Type is String.
Constant Value: "SceneType"
public static final String TAG_SENSING_METHOD
Type is int.
Constant Value: "SensingMethod"
public static final String TAG_SHUTTER_SPEED_VALUE
Type is rational.
Constant Value: "ShutterSpeedValue"
public static final String TAG_SPATIAL_FREQUENCY_RESPONSE
Type is String.
Constant Value: "SpatialFrequencyResponse"
public static final String TAG_SPECTRAL_SENSITIVITY
Type is String.
Constant Value: "SpectralSensitivity"
public static final String TAG_STRIP_BYTE_COUNTS
Type is int.
Constant Value: "StripByteCounts"
public static final String TAG_STRIP_OFFSETS
Type is int.
Constant Value: "StripOffsets"
public static final String TAG_SUBFILE_TYPE
Type is int.
Constant Value: "SubfileType"
public static final String TAG_SUBJECT_AREA
Type is int.
Constant Value: "SubjectArea"
public static final String TAG_SUBJECT_DISTANCE
Type is double.
Constant Value: "SubjectDistance"
public static final String TAG_SUBJECT_DISTANCE_RANGE
Type is int.
Constant Value: "SubjectDistanceRange"
public static final String TAG_SUBJECT_LOCATION
Type is int.
Constant Value: "SubjectLocation"
public static final String TAG_SUBSEC_TIME
Type is String.
Constant Value: "SubSecTime"
public static final String TAG_SUBSEC_TIME_DIG
This constant is deprecated.
use TAG_SUBSEC_TIME_DIGITIZED
instead
Type is String.
Constant Value: "SubSecTimeDigitized"
public static final String TAG_SUBSEC_TIME_DIGITIZED
Type is String.
Constant Value: "SubSecTimeDigitized"
public static final String TAG_SUBSEC_TIME_ORIG
This constant is deprecated.
use TAG_SUBSEC_TIME_ORIGINAL
instead
Type is String.
Constant Value: "SubSecTimeOriginal"
public static final String TAG_SUBSEC_TIME_ORIGINAL
Type is String.
Constant Value: "SubSecTimeOriginal"
public static final String TAG_THUMBNAIL_IMAGE_LENGTH
Type is int.
Constant Value: "ThumbnailImageLength"
public static final String TAG_THUMBNAIL_IMAGE_WIDTH
Type is int.
Constant Value: "ThumbnailImageWidth"
public static final String TAG_THUMBNAIL_ORIENTATION
Type is int.
Constant Value: "ThumbnailOrientation"
public static final String TAG_TRANSFER_FUNCTION
Type is int.
Constant Value: "TransferFunction"
public static final String TAG_USER_COMMENT
Type is String.
Constant Value: "UserComment"
public static final String TAG_WHITE_BALANCE
Type is int.
Constant Value: "WhiteBalance"
public static final String TAG_WHITE_POINT
Type is rational.
Constant Value: "WhitePoint"
public static final String TAG_XMP
Type is byte[]. See Extensible Metadata Platform (XMP) for details on contents.
Constant Value: "Xmp"
public static final String TAG_X_RESOLUTION
Type is rational.
Constant Value: "XResolution"
public static final String TAG_Y_CB_CR_COEFFICIENTS
Type is rational.
Constant Value: "YCbCrCoefficients"
public static final String TAG_Y_CB_CR_POSITIONING
Type is int.
Constant Value: "YCbCrPositioning"
public static final String TAG_Y_CB_CR_SUB_SAMPLING
Type is int.
Constant Value: "YCbCrSubSampling"
public static final String TAG_Y_RESOLUTION
Type is rational.
Constant Value: "YResolution"
public static final int WHITEBALANCE_AUTO
Constant Value: 0 (0x00000000)
public static final int WHITEBALANCE_MANUAL
Constant Value: 1 (0x00000001)
public ExifInterface (File file)
Reads Exif tags from the specified image file.
Parameters | |
---|---|
file |
File : the file of the image data
This value cannot be null . |
Throws | |
---|---|
NullPointerException |
if file is null |
IOException |
if an I/O error occurs while retrieving file descriptor via
FileInputStream#getFD() . |
public ExifInterface (String filename)
Reads Exif tags from the specified image file.
Parameters | |
---|---|
filename |
String : the name of the file of the image data
This value cannot be null . |
Throws | |
---|---|
NullPointerException |
if file name is null |
IOException |
if an I/O error occurs while retrieving file descriptor via
FileInputStream#getFD() . |
public 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 : the file descriptor of the image data
This value cannot be null . |
Throws | |
---|---|
NullPointerException |
if file descriptor is null |
IOException |
if an error occurs while duplicating the file descriptor via
Os#dup(FileDescriptor) . |
public 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 from its current position. Developers should close the input stream after use. This constructor is not intended to be used with an input stream that performs any networking operations.
Parameters | |
---|---|
inputStream |
InputStream : the input stream that contains the image data
This value cannot be null . |
Throws | |
---|---|
NullPointerException |
if the input stream is null |
IOException |
public ExifInterface (InputStream inputStream, int streamType)
Reads Exif tags from the specified image input stream based on the stream type. Attribute mutation is not supported for input streams. The given input stream will proceed from its current position. Developers should close the input stream after use. This constructor is not intended to be used with an input stream that performs any networking operations.
Parameters | |
---|---|
inputStream |
InputStream : the input stream that contains the image data
This value cannot be null . |
streamType |
int : the type of input stream
Value is STREAM_TYPE_FULL_IMAGE_DATA , or STREAM_TYPE_EXIF_DATA_ONLY |
Throws | |
---|---|
NullPointerException |
if the input stream is null |
IOException |
if an I/O error occurs while retrieving file descriptor via
FileInputStream#getFD() . |
public 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 |
public 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.
This value cannot be null . |
Returns | |
---|---|
String |
public byte[] getAttributeBytes (String tag)
Returns the raw bytes for the value of the requested tag inside the image
file, or null
if the tag is not contained.
Parameters | |
---|---|
tag |
String : This value cannot be null . |
Returns | |
---|---|
byte[] |
raw bytes for the value of the requested tag, or null if
no tag was found. |
public 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.
This value cannot be null . |
defaultValue |
double : the value to return if the tag is not available. |
Returns | |
---|---|
double |
public 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.
This value cannot be null . |
defaultValue |
int : the value to return if the tag is not available. |
Returns | |
---|---|
int |
public long[] getAttributeRange (String tag)
Returns the offset and length of the requested tag inside the image file,
or null
if the tag is not contained.
Parameters | |
---|---|
tag |
String : This value cannot be null . |
Returns | |
---|---|
long[] |
two-element array, the offset in the first value, and length in
the second, or null if no tag was found. |
Throws | |
---|---|
IllegalStateException |
if saveAttributes() has been
called since the underlying file was initially parsed, since
that means offsets may have changed. |
public long getDateTime ()
Returns parsed TAG_DATETIME
value, or -1 if unavailable or invalid.
Value is a non-negative timestamp measured as the number of
milliseconds since 1970-01-01T00:00:00Z.
Returns | |
---|---|
long |
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
public long getDateTimeDigitized ()
Returns parsed TAG_DATETIME_DIGITIZED
value, or -1 if unavailable or invalid.
Value is a non-negative timestamp measured as the number of
milliseconds since 1970-01-01T00:00:00Z.
Returns | |
---|---|
long |
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
public long getDateTimeOriginal ()
Returns parsed TAG_DATETIME_ORIGINAL
value, or -1 if unavailable or invalid.
Value is a non-negative timestamp measured as the number of
milliseconds since 1970-01-01T00:00:00Z.
Returns | |
---|---|
long |
Value is a non-negative timestamp measured as the number of milliseconds since 1970-01-01T00:00:00Z. |
public long getGpsDateTime ()
Returns number of milliseconds since Jan. 1, 1970, midnight UTC. Returns -1 if the date time information if not available.
Returns | |
---|---|
long |
public 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 |
public byte[] getThumbnail ()
Returns the JPEG compressed thumbnail inside the image file, or null
if there is no
JPEG compressed thumbnail.
The returned data can be decoded using
BitmapFactory.decodeByteArray(byte[], int, int)
Returns | |
---|---|
byte[] |
public Bitmap getThumbnailBitmap ()
Creates and returns a Bitmap object of the thumbnail image based on the byte array and the
thumbnail compression value, or null
if the compression type is unsupported.
Returns | |
---|---|
Bitmap |
public byte[] getThumbnailBytes ()
Returns the thumbnail bytes inside the image file, regardless of the compression type of the thumbnail image.
Returns | |
---|---|
byte[] |
public long[] getThumbnailRange ()
Returns the offset and length of thumbnail inside the image file, or
null
if either there is no thumbnail or the thumbnail bytes are stored
non-consecutively.
Returns | |
---|---|
long[] |
two-element array, the offset in the first value, and length in
the second, or null if no thumbnail was found or the thumbnail strips are
not placed consecutively. |
Throws | |
---|---|
IllegalStateException |
if saveAttributes() has been
called since the underlying file was initially parsed, since
that means offsets may have changed. |
public boolean hasAttribute (String tag)
Returns true if the image file has the given attribute defined.
Parameters | |
---|---|
tag |
String : the name of the tag.
This value cannot be null . |
Returns | |
---|---|
boolean |
public boolean hasThumbnail ()
Returns true if the image file has a thumbnail.
Returns | |
---|---|
boolean |
public static boolean isSupportedMimeType (String mimeType)
Returns whether ExifInterface currently supports reading data from the specified mime type or not.
Parameters | |
---|---|
mimeType |
String : the string value of mime type
This value cannot be null . |
Returns | |
---|---|
boolean |
public boolean isThumbnailCompressed ()
Returns true if thumbnail image is JPEG Compressed, or false if either thumbnail image does not exist or thumbnail image is uncompressed.
Returns | |
---|---|
boolean |
public 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(java.lang.String, java.lang.String)
to set all attributes to write and
make a single call rather than multiple calls for each attribute.
This method is supported for JPEG, PNG and WebP files.
Note: after calling this method, any attempts to obtain range information
from getAttributeRange(java.lang.String)
or getThumbnailRange()
will throw IllegalStateException
, since the offsets may have
changed in the newly written file.
For WebP format, the Exif data will be stored as an Extended File Format, and it may not be supported for older readers.
Throws | |
---|---|
IOException |