Class ExifInterface
-
- All Implemented Interfaces:
public class ExifInterface
This class provides methods and constants for reading and writing jpeg file metadata. It contains a collection of ExifTags, and a collection of definitions for creating valid ExifTags. The collection of ExifTags can be updated by: reading new ones from a file, deleting or adding existing ones, or building new ExifTags from a tag definition. These ExifTags can be written to a valid jpeg image as exif metadata.
Each ExifTag has a tag ID (TID) and is stored in a specific image file directory (IFD) as specified by the exif standard. A tag definition can be looked up with a constant that is a combination of TID and IFD. This definition has information about the type, number of components, and valid IFDs for a tag.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description public interface
ExifInterface.Orientation
Constants for TAG_ORIENTATION. They can be interpreted as follows:
- TOP_LEFT is the normal orientation.
- TOP_RIGHT is a left-right mirror.
- BOTTOM_LEFT is a 180 degree rotation.
- BOTTOM_RIGHT is a top-bottom mirror.
- LEFT_TOP is mirrored about the top-left<->bottom-right axis.
- RIGHT_TOP is a 90 degree clockwise rotation.
- LEFT_BOTTOM is mirrored about the top-right<->bottom-left axis.
- RIGHT_BOTTOM is a 270 degree clockwise rotation.
public interface
ExifInterface.YCbCrPositioning
Constants for TAG_Y_CB_CR_POSITIONING
public interface
ExifInterface.Compression
Constants for TAG_COMPRESSION
public interface
ExifInterface.ResolutionUnit
Constants for TAG_RESOLUTION_UNIT
public interface
ExifInterface.PhotometricInterpretation
Constants for TAG_PHOTOMETRIC_INTERPRETATION
public interface
ExifInterface.PlanarConfiguration
Constants for TAG_PLANAR_CONFIGURATION
public interface
ExifInterface.ExposureProgram
Constants for TAG_EXPOSURE_PROGRAM
public interface
ExifInterface.MeteringMode
Constants for TAG_METERING_MODE
public interface
ExifInterface.Flash
Constants for TAG_FLASH As the definition in Jeita EXIF 2.2 standard, we can treat this constant as bitwise flag.
e.g.
short flash = FIRED | RETURN_STROBE_RETURN_LIGHT_DETECTED | MODE_AUTO_MODE
public interface
ExifInterface.ColorSpace
Constants for TAG_COLOR_SPACE
public interface
ExifInterface.ExposureMode
Constants for TAG_EXPOSURE_MODE
public interface
ExifInterface.WhiteBalance
Constants for TAG_WHITE_BALANCE
public interface
ExifInterface.SceneCapture
Constants for TAG_SCENE_CAPTURE_TYPE
public interface
ExifInterface.ComponentsConfiguration
Constants for TAG_COMPONENTS_CONFIGURATION
public interface
ExifInterface.LightSource
Constants for TAG_LIGHT_SOURCE
public interface
ExifInterface.SensingMethod
Constants for TAG_SENSING_METHOD
public interface
ExifInterface.FileSource
Constants for TAG_FILE_SOURCE
public interface
ExifInterface.SceneType
Constants for TAG_SCENE_TYPE
public interface
ExifInterface.GainControl
Constants for TAG_GAIN_CONTROL
public interface
ExifInterface.Contrast
Constants for TAG_CONTRAST
public interface
ExifInterface.Saturation
Constants for TAG_SATURATION
public interface
ExifInterface.Sharpness
Constants for TAG_SHARPNESS
public interface
ExifInterface.SubjectDistance
Constants for TAG_SUBJECT_DISTANCE
public interface
ExifInterface.GpsLatitudeRef
Constants for TAG_GPS_LATITUDE_REF, TAG_GPS_DEST_LATITUDE_REF
public interface
ExifInterface.GpsLongitudeRef
Constants for TAG_GPS_LONGITUDE_REF, TAG_GPS_DEST_LONGITUDE_REF
public interface
ExifInterface.GpsAltitudeRef
Constants for TAG_GPS_ALTITUDE_REF
public interface
ExifInterface.GpsStatus
Constants for TAG_GPS_STATUS
public interface
ExifInterface.GpsMeasureMode
Constants for TAG_GPS_MEASURE_MODE
public interface
ExifInterface.GpsSpeedRef
Constants for TAG_GPS_SPEED_REF, TAG_GPS_DEST_DISTANCE_REF
public interface
ExifInterface.GpsTrackRef
Constants for TAG_GPS_TRACK_REF, TAG_GPS_IMG_DIRECTION_REF, TAG_GPS_DEST_BEARING_REF
public interface
ExifInterface.GpsDifferential
Constants for TAG_GPS_DIFFERENTIAL
-
Field Summary
Fields Modifier and Type Field Description public final static int
TAG_NULL
public final static int
IFD_NULL
public final static int
DEFINITION_NULL
public final static int
TAG_IMAGE_WIDTH
public final static int
TAG_IMAGE_LENGTH
public final static int
TAG_BITS_PER_SAMPLE
public final static int
TAG_COMPRESSION
public final static int
TAG_PHOTOMETRIC_INTERPRETATION
public final static int
TAG_IMAGE_DESCRIPTION
public final static int
TAG_MAKE
public final static int
TAG_MODEL
public final static int
TAG_STRIP_OFFSETS
public final static int
TAG_ORIENTATION
public final static int
TAG_SAMPLES_PER_PIXEL
public final static int
TAG_ROWS_PER_STRIP
public final static int
TAG_STRIP_BYTE_COUNTS
public final static int
TAG_X_RESOLUTION
public final static int
TAG_Y_RESOLUTION
public final static int
TAG_PLANAR_CONFIGURATION
public final static int
TAG_RESOLUTION_UNIT
public final static int
TAG_TRANSFER_FUNCTION
public final static int
TAG_SOFTWARE
public final static int
TAG_DATE_TIME
public final static int
TAG_ARTIST
public final static int
TAG_WHITE_POINT
public final static int
TAG_PRIMARY_CHROMATICITIES
public final static int
TAG_Y_CB_CR_COEFFICIENTS
public final static int
TAG_Y_CB_CR_SUB_SAMPLING
public final static int
TAG_Y_CB_CR_POSITIONING
public final static int
TAG_REFERENCE_BLACK_WHITE
public final static int
TAG_COPYRIGHT
public final static int
TAG_EXIF_IFD
public final static int
TAG_GPS_IFD
public final static int
TAG_JPEG_INTERCHANGE_FORMAT
public final static int
TAG_JPEG_INTERCHANGE_FORMAT_LENGTH
public final static int
TAG_EXPOSURE_TIME
public final static int
TAG_F_NUMBER
public final static int
TAG_EXPOSURE_PROGRAM
public final static int
TAG_SPECTRAL_SENSITIVITY
public final static int
TAG_ISO_SPEED_RATINGS
public final static int
TAG_OECF
public final static int
TAG_EXIF_VERSION
public final static int
TAG_DATE_TIME_ORIGINAL
public final static int
TAG_DATE_TIME_DIGITIZED
public final static int
TAG_COMPONENTS_CONFIGURATION
public final static int
TAG_COMPRESSED_BITS_PER_PIXEL
public final static int
TAG_SHUTTER_SPEED_VALUE
public final static int
TAG_APERTURE_VALUE
public final static int
TAG_BRIGHTNESS_VALUE
public final static int
TAG_EXPOSURE_BIAS_VALUE
public final static int
TAG_MAX_APERTURE_VALUE
public final static int
TAG_SUBJECT_DISTANCE
public final static int
TAG_METERING_MODE
public final static int
TAG_LIGHT_SOURCE
public final static int
TAG_FLASH
public final static int
TAG_FOCAL_LENGTH
public final static int
TAG_SUBJECT_AREA
public final static int
TAG_MAKER_NOTE
public final static int
TAG_USER_COMMENT
public final static int
TAG_SUB_SEC_TIME
public final static int
TAG_SUB_SEC_TIME_ORIGINAL
public final static int
TAG_SUB_SEC_TIME_DIGITIZED
public final static int
TAG_FLASHPIX_VERSION
public final static int
TAG_COLOR_SPACE
public final static int
TAG_PIXEL_X_DIMENSION
public final static int
TAG_PIXEL_Y_DIMENSION
public final static int
TAG_RELATED_SOUND_FILE
public final static int
TAG_INTEROPERABILITY_IFD
public final static int
TAG_FLASH_ENERGY
public final static int
TAG_SPATIAL_FREQUENCY_RESPONSE
public final static int
TAG_FOCAL_PLANE_X_RESOLUTION
public final static int
TAG_FOCAL_PLANE_Y_RESOLUTION
public final static int
TAG_FOCAL_PLANE_RESOLUTION_UNIT
public final static int
TAG_SUBJECT_LOCATION
public final static int
TAG_EXPOSURE_INDEX
public final static int
TAG_SENSING_METHOD
public final static int
TAG_FILE_SOURCE
public final static int
TAG_SCENE_TYPE
public final static int
TAG_CFA_PATTERN
public final static int
TAG_CUSTOM_RENDERED
public final static int
TAG_EXPOSURE_MODE
public final static int
TAG_WHITE_BALANCE
public final static int
TAG_DIGITAL_ZOOM_RATIO
public final static int
TAG_FOCAL_LENGTH_IN_35_MM_FILE
public final static int
TAG_SCENE_CAPTURE_TYPE
public final static int
TAG_GAIN_CONTROL
public final static int
TAG_CONTRAST
public final static int
TAG_SATURATION
public final static int
TAG_SHARPNESS
public final static int
TAG_DEVICE_SETTING_DESCRIPTION
public final static int
TAG_SUBJECT_DISTANCE_RANGE
public final static int
TAG_IMAGE_UNIQUE_ID
public final static int
TAG_GPS_VERSION_ID
public final static int
TAG_GPS_LATITUDE_REF
public final static int
TAG_GPS_LATITUDE
public final static int
TAG_GPS_LONGITUDE_REF
public final static int
TAG_GPS_LONGITUDE
public final static int
TAG_GPS_ALTITUDE_REF
public final static int
TAG_GPS_ALTITUDE
public final static int
TAG_GPS_TIME_STAMP
public final static int
TAG_GPS_SATTELLITES
public final static int
TAG_GPS_STATUS
public final static int
TAG_GPS_MEASURE_MODE
public final static int
TAG_GPS_DOP
public final static int
TAG_GPS_SPEED_REF
public final static int
TAG_GPS_SPEED
public final static int
TAG_GPS_TRACK_REF
public final static int
TAG_GPS_TRACK
public final static int
TAG_GPS_IMG_DIRECTION_REF
public final static int
TAG_GPS_IMG_DIRECTION
public final static int
TAG_GPS_MAP_DATUM
public final static int
TAG_GPS_DEST_LATITUDE_REF
public final static int
TAG_GPS_DEST_LATITUDE
public final static int
TAG_GPS_DEST_LONGITUDE_REF
public final static int
TAG_GPS_DEST_LONGITUDE
public final static int
TAG_GPS_DEST_BEARING_REF
public final static int
TAG_GPS_DEST_BEARING
public final static int
TAG_GPS_DEST_DISTANCE_REF
public final static int
TAG_GPS_DEST_DISTANCE
public final static int
TAG_GPS_PROCESSING_METHOD
public final static int
TAG_GPS_AREA_INFORMATION
public final static int
TAG_GPS_DATE_STAMP
public final static int
TAG_GPS_DIFFERENTIAL
public final static int
TAG_INTEROPERABILITY_INDEX
public final static ByteOrder
DEFAULT_BYTE_ORDER
-
Constructor Summary
Constructors Constructor Description ExifInterface()
-
Method Summary
Modifier and Type Method Description static int
defineTag(int ifdId, short tagId)
Returns the constant representing a tag with a given TID and default IFD. static short
getTrueTagKey(int tag)
Returns the TID for a tag constant. static int
getTrueIfd(int tag)
Returns the default IFD for a tag constant. void
readExif(Array<byte> jpeg)
Reads the exif tags from a byte array, clearing this ExifInterface object's existing exif tags. void
readExif(InputStream inStream)
Reads the exif tags from an InputStream, clearing this ExifInterface object's existing exif tags. void
readExif(String inFileName)
Reads the exif tags from a file, clearing this ExifInterface object's existing exif tags. void
setExif(Collection<ExifTag> tags)
Sets the exif tags, clearing this ExifInterface object's existing exif tags. void
clearExif()
Clears this ExifInterface object's existing exif tags. void
writeExif(Array<byte> jpeg, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg image, removing prior exif tags. void
writeExif(Bitmap bmap, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg compressed bitmap, removing prior exif tags. void
writeExif(InputStream jpegStream, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg stream, removing prior exif tags. void
writeExif(Array<byte> jpeg, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg image, removing prior exif tags. void
writeExif(Bitmap bmap, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg compressed bitmap, removing prior exif tags. void
writeExif(InputStream jpegStream, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg stream, removing prior exif tags. void
writeExif(String jpegFileName, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg file, removing prior exif tags. OutputStream
getExifWriterStream(OutputStream outStream)
Wraps an OutputStream object with an ExifOutputStream. OutputStream
getExifWriterStream(String exifOutFileName)
Returns an OutputStream object that writes to a file. boolean
rewriteExif(String filename, Collection<ExifTag> tags)
Attempts to do an in-place rewrite the exif metadata in a file for the given tags. boolean
rewriteExif(ByteBuffer buf, Collection<ExifTag> tags)
Attempts to do an in-place rewrite the exif metadata in a ByteBuffer for the given tags. void
forceRewriteExif(String filename, Collection<ExifTag> tags)
Attempts to do an in-place rewrite of the exif metadata. void
forceRewriteExif(String filename)
Attempts to do an in-place rewrite of the exif metadata using the tags in this ExifInterface object. List<ExifTag>
getAllTags()
Get the exif tags in this ExifInterface object or null if none exist. List<ExifTag>
getTagsForTagId(short tagId)
Returns a list of ExifTags that share a TID (which can be obtained by calling getTrueTagKey on a defined tag constant) or null if none exist. List<ExifTag>
getTagsForIfdId(int ifdId)
Returns a list of ExifTags that share an IFD (which can be obtained by calling getTrueIFD on a defined tag constant) or null if none exist. ExifTag
getTag(int tagId, int ifdId)
Gets an ExifTag for an IFD other than the tag's default. ExifTag
getTag(int tagId)
Returns the ExifTag in that tag's default IFD for a defined tag constant or null if none exists. Object
getTagValue(int tagId, int ifdId)
Gets a tag value for an IFD other than the tag's default. Object
getTagValue(int tagId)
Returns the value of the ExifTag in that tag's default IFD for a defined tag constant or null if none exists or the value could not be cast into the return type. String
getTagStringValue(int tagId, int ifdId)
String
getTagStringValue(int tagId)
Long
getTagLongValue(int tagId, int ifdId)
Long
getTagLongValue(int tagId)
Integer
getTagIntValue(int tagId, int ifdId)
Integer
getTagIntValue(int tagId)
Byte
getTagByteValue(int tagId, int ifdId)
Byte
getTagByteValue(int tagId)
Rational
getTagRationalValue(int tagId, int ifdId)
Rational
getTagRationalValue(int tagId)
Array<long>
getTagLongValues(int tagId, int ifdId)
Array<long>
getTagLongValues(int tagId)
Array<int>
getTagIntValues(int tagId, int ifdId)
Array<int>
getTagIntValues(int tagId)
Array<byte>
getTagByteValues(int tagId, int ifdId)
Array<byte>
getTagByteValues(int tagId)
Array<Rational>
getTagRationalValues(int tagId, int ifdId)
Array<Rational>
getTagRationalValues(int tagId)
boolean
isTagCountDefined(int tagId)
Checks whether a tag has a defined number of elements. int
getDefinedTagCount(int tagId)
Gets the defined number of elements for a tag. int
getActualTagCount(int tagId, int ifdId)
Gets the number of elements for an ExifTag in a given IFD. int
getDefinedTagDefaultIfd(int tagId)
Gets the default IFD for a tag. short
getDefinedTagType(int tagId)
Gets the defined type for a tag. ExifTag
buildTag(int tagId, int ifdId, Object val)
Creates a tag for a defined tag constant in a given IFD if that IFD is allowed for the tag. ExifTag
buildTag(int tagId, Object val)
Creates a tag for a defined tag constant in the tag's default IFD. boolean
setTagValue(int tagId, int ifdId, Object val)
Sets the value of an ExifTag if it exists in the given IFD. boolean
setTagValue(int tagId, Object val)
Sets the value of an ExifTag if it exists it's default IFD. ExifTag
setTag(ExifTag tag)
Puts an ExifTag into this ExifInterface object's tags, removing a previous ExifTag with the same TID and IFD. void
setTags(Collection<ExifTag> tags)
Puts a collection of ExifTags into this ExifInterface objects's tags. void
deleteTag(int tagId, int ifdId)
Removes the ExifTag for a tag constant from the given IFD. void
deleteTag(int tagId)
Removes the ExifTag for a tag constant from that tag's default IFD. int
setTagDefinition(short tagId, int defaultIfd, short tagType, short defaultComponentCount, Array<int> allowedIfds)
Creates a new tag definition in this ExifInterface object for a given TID and default IFD. void
removeTagDefinition(int tagId)
Removes a tag definition for given defined tag constant. void
resetTagDefinitions()
Resets tag definitions to the default ones. Bitmap
getThumbnailBitmap()
Returns the thumbnail from IFD1 as a bitmap, or null if none exists. Array<byte>
getThumbnailBytes()
Returns the thumbnail from IFD1 as a byte array, or null if none exists. Array<byte>
getThumbnail()
Returns the thumbnail if it is jpeg compressed, or null if none exists. boolean
isThumbnailCompressed()
Check if thumbnail is compressed. boolean
hasThumbnail()
Check if thumbnail exists. boolean
setCompressedThumbnail(Array<byte> thumb)
Sets the thumbnail to be a jpeg compressed image. boolean
setCompressedThumbnail(Bitmap thumb)
Sets the thumbnail to be a jpeg compressed bitmap. void
removeCompressedThumbnail()
Clears the compressed thumbnail if it exists. String
getUserComment()
Decodes the user comment tag into string as specified in the EXIF standard. static short
getOrientationValueForRotation(int degrees)
Returns the Orientation ExifTag value for a given number of degrees. static int
getRotationForOrientationValue(short orientation)
Returns the rotation degrees corresponding to an ExifTag Orientation value. static double
convertLatOrLongToDouble(Array<Rational> coordinate, String reference)
Gets the double representation of the GPS latitude or longitude coordinate. Array<double>
getLatLongAsDoubles()
Gets the GPS latitude and longitude as a pair of doubles from this ExifInterface object's tags, or null if the necessary tags do not exist. boolean
addDateTimeStampTag(int tagId, long timestamp, TimeZone timezone)
Creates, formats, and sets the DateTimeStamp tag for one of: TAG_DATE_TIME, TAG_DATE_TIME_DIGITIZED, TAG_DATE_TIME_ORIGINAL. boolean
addGpsTags(double latitude, double longitude)
Creates and sets all to the GPS tags for a give latitude and longitude. boolean
addGpsDateTimeStampTag(long timestamp)
Creates and sets the GPS timestamp tag. -
-
Method Detail
-
defineTag
static int defineTag(int ifdId, short tagId)
Returns the constant representing a tag with a given TID and default IFD.
-
getTrueTagKey
static short getTrueTagKey(int tag)
Returns the TID for a tag constant.
-
getTrueIfd
static int getTrueIfd(int tag)
Returns the default IFD for a tag constant.
-
readExif
void readExif(Array<byte> jpeg)
Reads the exif tags from a byte array, clearing this ExifInterface object's existing exif tags.
- Parameters:
jpeg
- a byte array containing a jpeg compressed image.
-
readExif
void readExif(InputStream inStream)
Reads the exif tags from an InputStream, clearing this ExifInterface object's existing exif tags.
- Parameters:
inStream
- an InputStream containing a jpeg compressed image.
-
readExif
void readExif(String inFileName)
Reads the exif tags from a file, clearing this ExifInterface object's existing exif tags.
- Parameters:
inFileName
- a string representing the filepath to jpeg file.
-
setExif
void setExif(Collection<ExifTag> tags)
Sets the exif tags, clearing this ExifInterface object's existing exif tags.
- Parameters:
tags
- a collection of exif tags to set.
-
clearExif
void clearExif()
Clears this ExifInterface object's existing exif tags.
-
writeExif
void writeExif(Array<byte> jpeg, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg image, removing prior exif tags.
- Parameters:
jpeg
- a byte array containing a jpeg compressed image.exifOutStream
- an OutputStream to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(Bitmap bmap, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg compressed bitmap, removing prior exif tags.
- Parameters:
bmap
- a bitmap to compress and write exif into.exifOutStream
- the OutputStream to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(InputStream jpegStream, OutputStream exifOutStream)
Writes the tags from this ExifInterface object into a jpeg stream, removing prior exif tags.
- Parameters:
jpegStream
- an InputStream containing a jpeg compressed image.exifOutStream
- an OutputStream to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(Array<byte> jpeg, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg image, removing prior exif tags.
- Parameters:
jpeg
- a byte array containing a jpeg compressed image.exifOutFileName
- a String containing the filepath to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(Bitmap bmap, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg compressed bitmap, removing prior exif tags.
- Parameters:
bmap
- a bitmap to compress and write exif into.exifOutFileName
- a String containing the filepath to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(InputStream jpegStream, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg stream, removing prior exif tags.
- Parameters:
jpegStream
- an InputStream containing a jpeg compressed image.exifOutFileName
- a String containing the filepath to which the jpeg image with added exif tags will be written.
-
writeExif
void writeExif(String jpegFileName, String exifOutFileName)
Writes the tags from this ExifInterface object into a jpeg file, removing prior exif tags.
- Parameters:
jpegFileName
- a String containing the filepath for a jpeg file.exifOutFileName
- a String containing the filepath to which the jpeg image with added exif tags will be written.
-
getExifWriterStream
OutputStream getExifWriterStream(OutputStream outStream)
Wraps an OutputStream object with an ExifOutputStream. Exif tags in this ExifInterface object will be added to a jpeg image written to this stream, removing prior exif tags. Other methods of this ExifInterface object should not be called until the returned OutputStream has been closed.
- Parameters:
outStream
- an OutputStream to wrap.
-
getExifWriterStream
OutputStream getExifWriterStream(String exifOutFileName)
Returns an OutputStream object that writes to a file. Exif tags in this ExifInterface object will be added to a jpeg image written to this stream, removing prior exif tags. Other methods of this ExifInterface object should not be called until the returned OutputStream has been closed.
- Parameters:
exifOutFileName
- an String containing a filepath for a jpeg file.
-
rewriteExif
boolean rewriteExif(String filename, Collection<ExifTag> tags)
Attempts to do an in-place rewrite the exif metadata in a file for the given tags. If tags do not exist or do not have the same size as the existing exif tags, this method will fail.
- Parameters:
filename
- a String containing a filepath for a jpeg file with exif tags to rewrite.tags
- tags that will be written into the jpeg file over existing tags if possible.
-
rewriteExif
boolean rewriteExif(ByteBuffer buf, Collection<ExifTag> tags)
Attempts to do an in-place rewrite the exif metadata in a ByteBuffer for the given tags. If tags do not exist or do not have the same size as the existing exif tags, this method will fail.
- Parameters:
buf
- a ByteBuffer containing a jpeg file with existing exif tags to rewrite.tags
- tags that will be written into the jpeg ByteBuffer over existing tags if possible.
-
forceRewriteExif
void forceRewriteExif(String filename, Collection<ExifTag> tags)
Attempts to do an in-place rewrite of the exif metadata. If this fails, fall back to overwriting file. This preserves tags that are not being rewritten.
- Parameters:
filename
- a String containing a filepath for a jpeg file.tags
- tags that will be written into the jpeg file over existing tags if possible.
-
forceRewriteExif
void forceRewriteExif(String filename)
Attempts to do an in-place rewrite of the exif metadata using the tags in this ExifInterface object. If this fails, fall back to overwriting file. This preserves tags that are not being rewritten.
- Parameters:
filename
- a String containing a filepath for a jpeg file.
-
getAllTags
List<ExifTag> getAllTags()
Get the exif tags in this ExifInterface object or null if none exist.
-
getTagsForTagId
List<ExifTag> getTagsForTagId(short tagId)
Returns a list of ExifTags that share a TID (which can be obtained by calling getTrueTagKey on a defined tag constant) or null if none exist.
- Parameters:
tagId
- a TID as defined in the exif standard (or with defineTag).
-
getTagsForIfdId
List<ExifTag> getTagsForIfdId(int ifdId)
Returns a list of ExifTags that share an IFD (which can be obtained by calling getTrueIFD on a defined tag constant) or null if none exist.
- Parameters:
ifdId
- an IFD as defined in the exif standard (or with defineTag).
-
getTag
ExifTag getTag(int tagId, int ifdId)
Gets an ExifTag for an IFD other than the tag's default.
-
getTag
ExifTag getTag(int tagId)
Returns the ExifTag in that tag's default IFD for a defined tag constant or null if none exists.
- Parameters:
tagId
- a defined tag constant, e.g.
-
getTagValue
Object getTagValue(int tagId, int ifdId)
Gets a tag value for an IFD other than the tag's default.
-
getTagValue
Object getTagValue(int tagId)
Returns the value of the ExifTag in that tag's default IFD for a defined tag constant or null if none exists or the value could not be cast into the return type.
- Parameters:
tagId
- a defined tag constant, e.g.
-
getTagStringValue
String getTagStringValue(int tagId, int ifdId)
-
getTagStringValue
String getTagStringValue(int tagId)
-
getTagLongValue
Long getTagLongValue(int tagId, int ifdId)
-
getTagLongValue
Long getTagLongValue(int tagId)
-
getTagIntValue
Integer getTagIntValue(int tagId, int ifdId)
-
getTagIntValue
Integer getTagIntValue(int tagId)
-
getTagByteValue
Byte getTagByteValue(int tagId, int ifdId)
-
getTagByteValue
Byte getTagByteValue(int tagId)
-
getTagRationalValue
Rational getTagRationalValue(int tagId, int ifdId)
-
getTagRationalValue
Rational getTagRationalValue(int tagId)
-
getTagLongValues
Array<long> getTagLongValues(int tagId, int ifdId)
-
getTagLongValues
Array<long> getTagLongValues(int tagId)
-
getTagIntValues
Array<int> getTagIntValues(int tagId, int ifdId)
-
getTagIntValues
Array<int> getTagIntValues(int tagId)
-
getTagByteValues
Array<byte> getTagByteValues(int tagId, int ifdId)
-
getTagByteValues
Array<byte> getTagByteValues(int tagId)
-
getTagRationalValues
Array<Rational> getTagRationalValues(int tagId, int ifdId)
-
getTagRationalValues
Array<Rational> getTagRationalValues(int tagId)
-
isTagCountDefined
boolean isTagCountDefined(int tagId)
Checks whether a tag has a defined number of elements.
- Parameters:
tagId
- a defined tag constant, e.g.
-
getDefinedTagCount
int getDefinedTagCount(int tagId)
Gets the defined number of elements for a tag.
- Parameters:
tagId
- a defined tag constant, e.g.
-
getActualTagCount
int getActualTagCount(int tagId, int ifdId)
Gets the number of elements for an ExifTag in a given IFD.
- Parameters:
tagId
- a defined tag constant, e.g.ifdId
- the IFD containing the ExifTag to check.
-
getDefinedTagDefaultIfd
int getDefinedTagDefaultIfd(int tagId)
Gets the default IFD for a tag.
- Parameters:
tagId
- a defined tag constant, e.g.
-
getDefinedTagType
short getDefinedTagType(int tagId)
Gets the defined type for a tag.
- Parameters:
tagId
- a defined tag constant, e.g.
-
buildTag
ExifTag buildTag(int tagId, int ifdId, Object val)
Creates a tag for a defined tag constant in a given IFD if that IFD is allowed for the tag. This method will fail anytime the appropriate setValue for this tag's datatype would fail.
- Parameters:
tagId
- a tag constant, e.g.ifdId
- the IFD that the tag should be in.val
- the value of the tag to set.
-
buildTag
ExifTag buildTag(int tagId, Object val)
Creates a tag for a defined tag constant in the tag's default IFD.
- Parameters:
tagId
- a tag constant, e.g.val
- the tag's value.
-
setTagValue
boolean setTagValue(int tagId, int ifdId, Object val)
Sets the value of an ExifTag if it exists in the given IFD. The value must be the correct type and length for that ExifTag.
- Parameters:
tagId
- a tag constant, e.g.ifdId
- the IFD that the ExifTag is in.val
- the value to set.
-
setTagValue
boolean setTagValue(int tagId, Object val)
Sets the value of an ExifTag if it exists it's default IFD. The value must be the correct type and length for that ExifTag.
- Parameters:
tagId
- a tag constant, e.g.val
- the value to set.
-
setTag
ExifTag setTag(ExifTag tag)
Puts an ExifTag into this ExifInterface object's tags, removing a previous ExifTag with the same TID and IFD. The IFD it is put into will be the one the tag was created with in buildTag.
- Parameters:
tag
- an ExifTag to put into this ExifInterface's tags.
-
setTags
void setTags(Collection<ExifTag> tags)
Puts a collection of ExifTags into this ExifInterface objects's tags. Any previous ExifTags with the same TID and IFDs will be removed.
- Parameters:
tags
- a Collection of ExifTags.
-
deleteTag
void deleteTag(int tagId, int ifdId)
Removes the ExifTag for a tag constant from the given IFD.
- Parameters:
tagId
- a tag constant, e.g.ifdId
- the IFD of the ExifTag to remove.
-
deleteTag
void deleteTag(int tagId)
Removes the ExifTag for a tag constant from that tag's default IFD.
- Parameters:
tagId
- a tag constant, e.g.
-
setTagDefinition
int setTagDefinition(short tagId, int defaultIfd, short tagType, short defaultComponentCount, Array<int> allowedIfds)
Creates a new tag definition in this ExifInterface object for a given TID and default IFD. Creating a definition with the same TID and default IFD as a previous definition will override it.
- Parameters:
tagId
- the TID for the tag.defaultIfd
- the default IFD for the tag.tagType
- the type of the tag (see getDataType).defaultComponentCount
- the number of elements of this tag's type in the tags value.allowedIfds
- the IFD's this tag is allowed to be put in.
-
removeTagDefinition
void removeTagDefinition(int tagId)
Removes a tag definition for given defined tag constant.
- Parameters:
tagId
- a defined tag constant, e.g.
-
resetTagDefinitions
void resetTagDefinitions()
Resets tag definitions to the default ones.
-
getThumbnailBitmap
Bitmap getThumbnailBitmap()
Returns the thumbnail from IFD1 as a bitmap, or null if none exists.
-
getThumbnailBytes
Array<byte> getThumbnailBytes()
Returns the thumbnail from IFD1 as a byte array, or null if none exists. The bytes may either be an uncompressed strip as specified in the exif standard or a jpeg compressed image.
-
getThumbnail
Array<byte> getThumbnail()
Returns the thumbnail if it is jpeg compressed, or null if none exists.
-
isThumbnailCompressed
boolean isThumbnailCompressed()
Check if thumbnail is compressed.
-
hasThumbnail
boolean hasThumbnail()
Check if thumbnail exists.
-
setCompressedThumbnail
boolean setCompressedThumbnail(Array<byte> thumb)
Sets the thumbnail to be a jpeg compressed image. Clears any prior thumbnail.
- Parameters:
thumb
- a byte array containing a jpeg compressed image.
-
setCompressedThumbnail
boolean setCompressedThumbnail(Bitmap thumb)
Sets the thumbnail to be a jpeg compressed bitmap. Clears any prior thumbnail.
- Parameters:
thumb
- a bitmap to compress to a jpeg thumbnail.
-
removeCompressedThumbnail
void removeCompressedThumbnail()
Clears the compressed thumbnail if it exists.
-
getUserComment
String getUserComment()
Decodes the user comment tag into string as specified in the EXIF standard. Returns null if decoding failed.
-
getOrientationValueForRotation
static short getOrientationValueForRotation(int degrees)
Returns the Orientation ExifTag value for a given number of degrees.
- Parameters:
degrees
- the amount an image is rotated in degrees.
-
getRotationForOrientationValue
static int getRotationForOrientationValue(short orientation)
Returns the rotation degrees corresponding to an ExifTag Orientation value.
- Parameters:
orientation
- the ExifTag Orientation value.
-
convertLatOrLongToDouble
static double convertLatOrLongToDouble(Array<Rational> coordinate, String reference)
Gets the double representation of the GPS latitude or longitude coordinate.
- Parameters:
coordinate
- an array of 3 Rationals representing the degrees, minutes, and seconds of the GPS location as defined in the exif specification.reference
- a GPS reference reperesented by a String containing "N", "S", "E", or "W".
-
getLatLongAsDoubles
Array<double> getLatLongAsDoubles()
Gets the GPS latitude and longitude as a pair of doubles from this ExifInterface object's tags, or null if the necessary tags do not exist.
-
addDateTimeStampTag
boolean addDateTimeStampTag(int tagId, long timestamp, TimeZone timezone)
Creates, formats, and sets the DateTimeStamp tag for one of: TAG_DATE_TIME, TAG_DATE_TIME_DIGITIZED, TAG_DATE_TIME_ORIGINAL.
- Parameters:
tagId
- one of the DateTimeStamp tags.timestamp
- a timestamp to format.timezone
- a TimeZone object.
-
addGpsTags
boolean addGpsTags(double latitude, double longitude)
Creates and sets all to the GPS tags for a give latitude and longitude.
- Parameters:
latitude
- a GPS latitude coordinate.longitude
- a GPS longitude coordinate.
-
addGpsDateTimeStampTag
boolean addGpsDateTimeStampTag(long timestamp)
Creates and sets the GPS timestamp tag.
- Parameters:
timestamp
- a GPS timestamp.
-
-
-
-