Exify

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

open class Exify

See also

ExifTagInfo

Constructors

Exify
Link copied to clipboard
open fun Exify()

Types

ColorSpace
Link copied to clipboard

Constants for {@see #ExifTagKey.COLOR_SPACE}

interface ColorSpace
ComponentsConfiguration
Link copied to clipboard

Constants for {@see #ExifTagKey.COMPONENTS_CONFIGURATION}

interface ComponentsConfiguration
Compression
Link copied to clipboard

Constants for {@see #ExifTagKey.COMPRESSION}

interface Compression
Contrast
Link copied to clipboard

Constants for {@see #ExifTagKey.CONTRAST}

interface Contrast
ExposureMode
Link copied to clipboard

Constants for {@see #ExifTagKey.EXPOSURE_MODE}

interface ExposureMode
ExposureProgram
Link copied to clipboard

Constants for {@see #ExifTagKey.EXPOSURE_PROGRAM}

interface ExposureProgram
FileSource
Link copied to clipboard

Constants for {@see #ExifTagKey.FILE_SOURCE}

interface FileSource
Flash
Link copied to clipboard

Constants for {@see #ExifTagKey.FLASH} As the definition in Jeita EXIF 2.2

interface Flash
GainControl
Link copied to clipboard

Constants for {@see #ExifTagKey.GAIN_CONTROL}

interface GainControl
GpsAltitudeRef
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_ALTITUDE_REF}

interface GpsAltitudeRef
GpsDifferential
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_DIFFERENTIAL}

interface GpsDifferential
GpsLatitudeRef
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_LATITUDE_REF} , {@see #ExifTagKey.GPS_DEST_LATITUDE_REF}

interface GpsLatitudeRef
GpsLongitudeRef
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_LONGITUDE_REF} , {@see #ExifTagKey.GPS_DEST_LONGITUDE_REF}

interface GpsLongitudeRef
GpsMeasureMode
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_MEASURE_MODE}

interface GpsMeasureMode
GpsSpeedRef
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_SPEED_REF} , {@see #ExifTagKey.GPS_DEST_DISTANCE_REF}

interface GpsSpeedRef
GpsStatus
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_STATUS}

interface GpsStatus
GpsTrackRef
Link copied to clipboard

Constants for {@see #ExifTagKey.GPS_TRACK_REF} , {@see #ExifTagKey.GPS_IMG_DIRECTION_REF} , {@see #ExifTagKey.GPS_DEST_BEARING_REF}

interface GpsTrackRef
JpegProcess
Link copied to clipboard

Constants for the jpeg process algorithm used.

interface JpegProcess
LightSource
Link copied to clipboard

Constants for {@see #ExifTagKey.LIGHT_SOURCE}

interface LightSource
MeteringMode
Link copied to clipboard

Constants for {@see #ExifTagKey.METERING_MODE}

interface MeteringMode
Options
Link copied to clipboard

Options for calling readExif , readExif , readExif

interface Options
Orientation
Link copied to clipboard

Constants for {@see #ExifTagKey.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.
  • TOP_RIGHT is a 90 degree clockwise rotation.
  • BOTTOM_LEFT is mirrored about the top-right<->bottom-left axis.
  • BOTTOM_RIGHT is a 270 degree clockwise rotation.

interface Orientation
PhotometricInterpretation
Link copied to clipboard

Constants for {@see #ExifTagKey.PHOTOMETRIC_INTERPRETATION}

interface PhotometricInterpretation
PlanarConfiguration
Link copied to clipboard

Constants for {@see #ExifTagKey.PLANAR_CONFIGURATION}

interface PlanarConfiguration
ResolutionUnit
Link copied to clipboard

Constants for {@see #ExifTagKey.RESOLUTION_UNIT}

interface ResolutionUnit
Saturation
Link copied to clipboard

Constants for {@see #ExifTagKey.SATURATION}

interface Saturation
SceneCapture
Link copied to clipboard

Constants for {@see #ExifTagKey.SCENE_CAPTURE_TYPE}

interface SceneCapture
SceneType
Link copied to clipboard

Constants for {@see #ExifTagKey.SCENE_TYPE}

interface SceneType
SensingMethod
Link copied to clipboard

Constants for {@see #ExifTagKey.SENSING_METHOD}

interface SensingMethod
SensitivityType
Link copied to clipboard

Constants for the {@see #ExifTagKey.SENSITIVITY_TYPE} tag

interface SensitivityType
Sharpness
Link copied to clipboard

Constants for {@see #ExifTagKey.SHARPNESS}

interface Sharpness
SubjectDistance
Link copied to clipboard

Constants for {@see #ExifTagKey.SUBJECT_DISTANCE}

interface SubjectDistance
TAG
Link copied to clipboard
enum TAG
WhiteBalance
Link copied to clipboard

Constants for {@see #ExifTagKey.WHITE_BALANCE}

interface WhiteBalance
YCbCrPositioning
Link copied to clipboard

Constants for {@see #ExifTagKey.Y_CB_CR_POSITIONING}

interface YCbCrPositioning

Functions

addDateTimeStampTag
Link copied to clipboard

Creates, formats, and sets the DateTimeStamp tag for one of: {@see #ExifTagKey.DATE_TIME} , {@see #ExifTagKey.DATE_TIME_DIGITIZED} , {@see #ExifTagKey.DATE_TIME_ORIGINAL} .

open fun addDateTimeStampTag(tag: Exify.TAG, timestamp: Long, timezone: TimeZone): Boolean
addGpsDateTimeStampTag
Link copied to clipboard

Creates and sets the GPS timestamp ExifTagKey.

open fun addGpsDateTimeStampTag(timestamp: Long): Boolean
addGpsTags
Link copied to clipboard

Creates and sets all to the GPS tags for a give latitude and longitude.

open fun addGpsTags(latitude: Double, longitude: Double): Boolean
buildTag
Link copied to clipboard

Creates a tag for a defined tag constant in the tag's default IFD.

open fun buildTag(tag: Exify.TAG, val: Any): ExifTagInfo

Creates a tag for a defined tag constant in a given IFD if that IFD is allowed for the ExifTagKey. This method will fail anytime the appropriate for this tag's datatype would fail.

open fun buildTag(tagId: Int, ifdId: Int, val: Any): ExifTagInfo
clearExif
Link copied to clipboard

Clears this ExifInterface object's existing exif tags.

open fun clearExif()
convertLatOrLongToDouble
Link copied to clipboard

Gets the double representation of the GPS latitude or longitude coordinate.

open fun convertLatOrLongToDouble(coordinate: Array<Rational>, reference: String): Double
defineTag
Link copied to clipboard

Returns the constant representing a tag with a given TID and default IFD.

open fun defineTag(ifdId: Int, tagId: Short): Int
deleteTag
Link copied to clipboard

Removes the ExifTag for a tag constant from that tag's default IFD.

open fun deleteTag(tagId: Int)
open fun deleteTag(tag: Exify.TAG)

Removes the ExifTag for a tag constant from the given IFD.

open fun deleteTag(tagId: Int, ifdId: Int)
getActualTagCount
Link copied to clipboard

Gets the number of elements for an ExifTag in a given IFD.

open fun getActualTagCount(tagId: Int, ifdId: Int): Int
getAllTags
Link copied to clipboard

Get the exif tags in this ExifInterface object or null if none exist.

open fun getAllTags(): List<ExifTagInfo>
getAltitude
Link copied to clipboard

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

open fun getAltitude(defaultValue: Double): Double
getApertureSize
Link copied to clipboard

Return the aperture size, if present, 0 if missing

open fun getApertureSize(): Double
getDateTime
Link copied to clipboard

Given an exif date time, like {@see #ExifTagKey.DATE_TIME} or {@see #ExifTagKey.DATE_TIME_DIGITIZED} returns a java Date object

open fun getDateTime(dateTimeString: String, timeZone: TimeZone): Date
getDefinedTagCount
Link copied to clipboard

Gets the defined number of elements for a ExifTagKey.

open fun getDefinedTagCount(tagId: Int): Int
open fun getDefinedTagCount(tag: Exify.TAG): Int
getDefinedTagDefaultIfd
Link copied to clipboard

Gets the default IFD for a ExifTagKey.

open fun getDefinedTagDefaultIfd(tagId: Int): Int
getDefinedTagType
Link copied to clipboard

Gets the defined type for a ExifTagKey.

open fun getDefinedTagType(tagId: Int): Short
getImageSize
Link copied to clipboard

Returns the Image size as decoded from the SOF marker

open fun getImageSize(): Array<Int>
getJpegProcess
Link copied to clipboard

this gives information about the process used to create the JPEG file. Possible values are:

  • '0' Unknown
  • '192' Baseline
  • '193' Extended sequential
  • '194' Progressive
  • '195' Lossless
  • '197' Differential sequential
  • '198' Differential progressive
  • '199' Differential lossless
  • '201' Extended sequential, arithmetic coding
  • '202' Progressive, arithmetic coding
  • '203' Lossless, arithmetic coding
  • '205' Differential sequential, arithmetic coding
  • '206' Differential progressive, arithmetic codng
  • '207' Differential lossless, arithmetic coding

open fun getJpegProcess(): Short
getLatitude
Link copied to clipboard

Returns a formatted String with the latitude representation: 39° 8' 16.8" N

open fun getLatitude(): String
getLatLongAsDoubles
Link copied to clipboard

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.

open fun getLatLongAsDoubles(): Array<Double>
getLensModelDescription
Link copied to clipboard

Returns the lens model as string if any of the tags {@see #ExifTagKey.LENS_MODEL} or {@see #ExifTagKey.LENS_SPECS} are found

open fun getLensModelDescription(): String
getLongitude
Link copied to clipboard

Returns a formatted String with the longitude representation: 77° 37' 51.6" W

open fun getLongitude(): String
getOrientationValueForRotation
Link copied to clipboard

Returns the Orientation ExifTag value for a given number of degrees.

open fun getOrientationValueForRotation(degrees: Int): Short
getQualityGuess
Link copied to clipboard

Returns the JPEG quality used to generate the image or 0 if not found

open fun getQualityGuess(): Int
getResolutionUnit
Link copied to clipboard

Given the value from {@see #ExifTagKey.FOCAL_PLANE_RESOLUTION_UNIT} or {@see #ExifTagKey.RESOLUTION_UNIT} this method will return the corresponding value in millimeters

open fun getResolutionUnit(resolution: Int): Double
getRotationForOrientationValue
Link copied to clipboard

Returns the rotation degrees corresponding to an ExifTag Orientation value.

open fun getRotationForOrientationValue(orientation: Short): Int
getTag
Link copied to clipboard

Returns the ExifTag in that tag's default IFD for a defined tag constant or null if none exists.

open fun getTag(tagId: Int): ExifTagInfo
open fun getTag(tag: Exify.TAG): ExifTagInfo

Gets an ExifTag for an IFD other than the tag's default.

open fun getTag(tagId: Int, ifdId: Int): ExifTagInfo
getTagByteValue
Link copied to clipboard
open fun getTagByteValue(tagId: Int): Byte
open fun getTagByteValue(tag: Exify.TAG): Byte
open fun getTagByteValue(tagId: Int, ifdId: Int): Byte
getTagByteValues
Link copied to clipboard
open fun getTagByteValues(tagId: Int): Array<Byte>
open fun getTagByteValues(tag: Exify.TAG): Array<Byte>
open fun getTagByteValues(tagId: Int, ifdId: Int): Array<Byte>
getTagIntValue
Link copied to clipboard
open fun getTagIntValue(tagId: Int): Integer
open fun getTagIntValue(tag: Exify.TAG): Integer
open fun getTagIntValue(tagId: Int, ifdId: Int): Integer
getTagIntValues
Link copied to clipboard
open fun getTagIntValues(tagId: Int): Array<Int>
open fun getTagIntValues(tag: Exify.TAG): Array<Int>
open fun getTagIntValues(tagId: Int, ifdId: Int): Array<Int>
getTagLongValue
Link copied to clipboard
open fun getTagLongValue(tagId: Int): Long
open fun getTagLongValue(tag: Exify.TAG): Long
open fun getTagLongValue(tagId: Int, ifdId: Int): Long
getTagLongValues
Link copied to clipboard
open fun getTagLongValues(tagId: Int): Array<Long>
open fun getTagLongValues(tag: Exify.TAG): Array<Long>
open fun getTagLongValues(tagId: Int, ifdId: Int): Array<Long>
getTagRationalValue
Link copied to clipboard
open fun getTagRationalValue(tagId: Int): Rational
open fun getTagRationalValue(tag: Exify.TAG): Rational
open fun getTagRationalValue(tagId: Int, ifdId: Int): Rational
getTagRationalValues
Link copied to clipboard
open fun getTagRationalValues(tagId: Int): Array<Rational>
open fun getTagRationalValues(tag: Exify.TAG): Array<Rational>
open fun getTagRationalValues(tagId: Int, ifdId: Int): Array<Rational>
getTagsForIfdId
Link copied to clipboard

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.

open fun getTagsForIfdId(ifdId: Int): List<ExifTagInfo>
getTagsForTagId
Link copied to clipboard

Returns a list of ExifTags that share a TID (which can be obtained by calling on a defined tag constant) or null if none exist.

open fun getTagsForTagId(tagId: Short): List<ExifTagInfo>
getTagStringValue
Link copied to clipboard
open fun getTagStringValue(tagId: Int): String
open fun getTagStringValue(tag: Exify.TAG): String
open fun getTagStringValue(tagId: Int, ifdId: Int): String
getTagValue
Link copied to clipboard

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.

open fun getTagValue(tagId: Int): Any
open fun getTagValue(tag: Exify.TAG): Any

Gets a tag value for an IFD other than the tag's default.

open fun getTagValue(tagId: Int, ifdId: Int): Any
getThumbnail
Link copied to clipboard

Returns the thumbnail if it is jpeg compressed, or null if none exists.

open fun getThumbnail(): Array<Byte>
getThumbnailBitmap
Link copied to clipboard

Returns the thumbnail from IFD1 as a bitmap, or null if none exists.

open fun getThumbnailBitmap(): Bitmap
getThumbnailBytes
Link copied to clipboard

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.

open fun getThumbnailBytes(): Array<Byte>
getTrueIfd
Link copied to clipboard

Returns the default IFD for a tag constant.

open fun getTrueIfd(tag: Int): Int
open fun getTrueIfd(tag: Exify.TAG): Int
getTrueTagKey
Link copied to clipboard

Returns the TID for a tag constant.

open fun getTrueTagKey(tag: Int): Short
open fun getTrueTagKey(tag: Exify.TAG): Short
getUserComment
Link copied to clipboard

Decodes the user comment tag into string as specified in the EXIF standard. Returns null if decoding failed.

open fun getUserComment(): String
hasThumbnail
Link copied to clipboard

Check if thumbnail exists.

open fun hasThumbnail(): Boolean
isTagCountDefined
Link copied to clipboard

Checks whether a tag has a defined number of elements.

open fun isTagCountDefined(tagId: Int): Boolean
isThumbnailCompressed
Link copied to clipboard

Check if thumbnail is compressed.

open fun isThumbnailCompressed(): Boolean
readExif
Link copied to clipboard

Reads the exif tags from a byte array, clearing this ExifInterface object's existing exif tags.

open fun readExif(jpeg: Array<Byte>, options: Int)

Reads the exif tags from an InputStream, clearing this ExifInterface object's existing exif tags.

    ExifInterface exif = new ExifInterface();
    exif.readExif( stream, Options.OPTION_IFD_0 | Options.OPTION_IFD_1 | Options.OPTION_IFD_EXIF );
    ...
    // to request all the options use the OPTION_ALL bit mask
    exif.readExif( stream, Options.OPTION_ALL );

open fun readExif(inStream: InputStream, options: Int)

Reads the exif tags from a file, clearing this ExifInterface object's existing exif tags.

open fun readExif(inFileName: String, options: Int)
removeCompressedThumbnail
Link copied to clipboard

Clears the compressed thumbnail if it exists.

open fun removeCompressedThumbnail()
removeTagDefinition
Link copied to clipboard

Removes a tag definition for given defined tag constant.

open fun removeTagDefinition(tagId: Int)
resetTagDefinitions
Link copied to clipboard

Resets tag definitions to the default ones.

open fun resetTagDefinitions()
setCompressedThumbnail
Link copied to clipboard

Sets the thumbnail to be a jpeg compressed bitmap. Clears any prior thumbnail.

open fun setCompressedThumbnail(thumb: Bitmap): Boolean

Sets the thumbnail to be a jpeg compressed image. Clears any prior thumbnail.

open fun setCompressedThumbnail(thumb: Array<Byte>): Boolean
setExif
Link copied to clipboard

Sets the exif tags, clearing this ExifInterface object's existing exif tags.

open fun setExif(tags: Collection<ExifTagInfo>)
setTag
Link copied to clipboard

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 .

open fun setTag(tag: ExifTagInfo): ExifTagInfo
setTagDefinition
Link copied to clipboard

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.

open fun setTagDefinition(tagId: Short, defaultIfd: Int, tagType: Short, defaultComponentCount: Short, allowedIfds: Array<Int>): Int
setTags
Link copied to clipboard

Puts a collection of ExifTags into this ExifInterface objects's tags. Any previous ExifTags with the same TID and IFDs will be removed.

open fun setTags(tags: Collection<ExifTagInfo>)
setTagValue
Link copied to clipboard

Sets the value of an ExifTag if it exists it's default IFD. The value must be the correct type and length for that ExifExifTagKey.

open fun setTagValue(tagId: Int, val: Any): Boolean
open fun setTagValue(tag: Exify.TAG, val: Any): Boolean

Sets the value of an ExifTag if it exists in the given IFD. The value must be the correct type and length for that ExifExifTagKey.

open fun setTagValue(tagId: Int, ifdId: Int, val: Any): Boolean
toBitArray
Link copied to clipboard
open fun toBitArray(value: Short): Array<Byte>
writeExif
Link copied to clipboard
open fun writeExif(input: InputStream, output: OutputStream)
open fun writeExif(srcFilename: String, dstFilename: String)
writeExifHeader
Link copied to clipboard
open fun writeExifHeader(input: InputStream, output: OutputStream)

Properties

DEFAULT_BYTE_ORDER
Link copied to clipboard
val DEFAULT_BYTE_ORDER: ByteOrder
DEFINITION_NULL
Link copied to clipboard
val DEFINITION_NULL: Int
IFD_NULL
Link copied to clipboard
val IFD_NULL: Int
TAG_NULL
Link copied to clipboard
val TAG_NULL: Int