metadata: added some TIFF tag names
This commit is contained in:
parent
a7c62d6306
commit
075bb2f07c
4 changed files with 143 additions and 57 deletions
|
@ -113,7 +113,7 @@ class MetadataHandler(private val context: Context) : MethodCallHandler {
|
|||
val name = if (it.hasTagName()) {
|
||||
it.tagName
|
||||
} else {
|
||||
Geotiff.getTagName(it.tagType) ?: it.tagName
|
||||
TiffTags.getTagName(it.tagType) ?: it.tagName
|
||||
}
|
||||
Pair(name, it.description)
|
||||
})
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
package deckers.thibault.aves.metadata
|
||||
|
||||
object Geotiff {
|
||||
// ModelPixelScaleTag (optional)
|
||||
// Tag = 33550 (830E.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 3
|
||||
const val TAG_MODEL_PIXEL_SCALE = 0x830e
|
||||
|
||||
// ModelTiepointTag (conditional)
|
||||
// Tag = 33922 (8482.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 6*K, K = number of tiepoints
|
||||
const val TAG_MODEL_TIEPOINT = 0x8482
|
||||
|
||||
// ModelTransformationTag (conditional)
|
||||
// Tag = 34264 (85D8.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 16
|
||||
const val TAG_MODEL_TRANSFORMATION = 0x85d8
|
||||
|
||||
// GeoKeyDirectoryTag (mandatory)
|
||||
// Tag = 34735 (87AF.H)
|
||||
// Type = UNSIGNED SHORT
|
||||
// Count = variable, >= 4
|
||||
const val TAG_GEO_KEY_DIRECTORY = 0x87af
|
||||
|
||||
// GeoDoubleParamsTag (optional)
|
||||
// Tag = 34736 (87BO.H)
|
||||
// Type = DOUBLE
|
||||
// Count = variable
|
||||
const val TAG_GEO_DOUBLE_PARAMS = 0x87b0
|
||||
|
||||
// GeoAsciiParamsTag (optional)
|
||||
// Tag = 34737 (87B1.H)
|
||||
// Type = ASCII
|
||||
// Count = variable
|
||||
val TAG_GEO_ASCII_PARAMS = 0x87b1
|
||||
|
||||
private val tagNameMap = hashMapOf(
|
||||
TAG_GEO_ASCII_PARAMS to "Geo Ascii Params",
|
||||
TAG_GEO_DOUBLE_PARAMS to "Geo Double Params",
|
||||
TAG_GEO_KEY_DIRECTORY to "Geo Key Directory",
|
||||
TAG_MODEL_PIXEL_SCALE to "Model Pixel Scale",
|
||||
TAG_MODEL_TIEPOINT to "Model Tiepoint",
|
||||
TAG_MODEL_TRANSFORMATION to "Model Transformation",
|
||||
)
|
||||
|
||||
fun getTagName(tag: Int): String? {
|
||||
return tagNameMap[tag]
|
||||
}
|
||||
}
|
|
@ -45,13 +45,13 @@ object MetadataExtractorHelper {
|
|||
- If the ModelPixelScaleTag is included in an IFD, then a ModelTiepointTag SHALL also be included.
|
||||
*/
|
||||
fun ExifIFD0Directory.isGeoTiff(): Boolean {
|
||||
if (!this.containsTag(Geotiff.TAG_GEO_KEY_DIRECTORY)) return false
|
||||
if (!this.containsTag(TiffTags.TAG_GEO_KEY_DIRECTORY)) return false
|
||||
|
||||
val modelTiepoint = this.containsTag(Geotiff.TAG_MODEL_TIEPOINT)
|
||||
val modelTransformation = this.containsTag(Geotiff.TAG_MODEL_TRANSFORMATION)
|
||||
val modelTiepoint = this.containsTag(TiffTags.TAG_MODEL_TIEPOINT)
|
||||
val modelTransformation = this.containsTag(TiffTags.TAG_MODEL_TRANSFORMATION)
|
||||
if (!modelTiepoint && !modelTransformation) return false
|
||||
|
||||
val modelPixelScale = this.containsTag(Geotiff.TAG_MODEL_PIXEL_SCALE)
|
||||
val modelPixelScale = this.containsTag(TiffTags.TAG_MODEL_PIXEL_SCALE)
|
||||
if ((modelTransformation && modelPixelScale) || (modelPixelScale && !modelTiepoint)) return false
|
||||
|
||||
return true
|
||||
|
|
|
@ -0,0 +1,138 @@
|
|||
package deckers.thibault.aves.metadata
|
||||
|
||||
object TiffTags {
|
||||
// XPosition
|
||||
// Tag = 286 (011E.H)
|
||||
const val TAG_X_POSITION = 0x011e
|
||||
|
||||
// YPosition
|
||||
// Tag = 287 (011F.H)
|
||||
const val TAG_Y_POSITION = 0x011f
|
||||
|
||||
// ColorMap
|
||||
// Tag = 320 (0140.H)
|
||||
const val TAG_COLOR_MAP = 0x0140
|
||||
|
||||
// ExtraSamples
|
||||
// Tag = 338 (0152.H)
|
||||
// values:
|
||||
// EXTRASAMPLE_UNSPECIFIED 0 // unspecified data
|
||||
// EXTRASAMPLE_ASSOCALPHA 1 // associated alpha data
|
||||
// EXTRASAMPLE_UNASSALPHA 2 // unassociated alpha data
|
||||
const val TAG_EXTRA_SAMPLES = 0x0152
|
||||
|
||||
// SampleFormat
|
||||
// Tag = 339 (0153.H)
|
||||
// values:
|
||||
// SAMPLEFORMAT_UINT 1 // unsigned integer data
|
||||
// SAMPLEFORMAT_INT 2 // signed integer data
|
||||
// SAMPLEFORMAT_IEEEFP 3 // IEEE floating point data
|
||||
// SAMPLEFORMAT_VOID 4 // untyped data
|
||||
// SAMPLEFORMAT_COMPLEXINT 5 // complex signed int
|
||||
// SAMPLEFORMAT_COMPLEXIEEEFP 6 // complex ieee floating
|
||||
const val TAG_SAMPLE_FORMAT = 0x0153
|
||||
|
||||
/*
|
||||
SGI
|
||||
tags 32995-32999
|
||||
*/
|
||||
|
||||
// Matteing
|
||||
// Tag = 32995 (80E3.H)
|
||||
// obsoleted by the 6.0 ExtraSamples (338)
|
||||
val TAG_MATTEING = 0x80e3
|
||||
|
||||
/*
|
||||
GeoTIFF
|
||||
*/
|
||||
|
||||
// ModelPixelScaleTag (optional)
|
||||
// Tag = 33550 (830E.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 3
|
||||
const val TAG_MODEL_PIXEL_SCALE = 0x830e
|
||||
|
||||
// ModelTiepointTag (conditional)
|
||||
// Tag = 33922 (8482.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 6*K, K = number of tiepoints
|
||||
const val TAG_MODEL_TIEPOINT = 0x8482
|
||||
|
||||
// ModelTransformationTag (conditional)
|
||||
// Tag = 34264 (85D8.H)
|
||||
// Type = DOUBLE
|
||||
// Count = 16
|
||||
const val TAG_MODEL_TRANSFORMATION = 0x85d8
|
||||
|
||||
// GeoKeyDirectoryTag (mandatory)
|
||||
// Tag = 34735 (87AF.H)
|
||||
// Type = UNSIGNED SHORT
|
||||
// Count = variable, >= 4
|
||||
const val TAG_GEO_KEY_DIRECTORY = 0x87af
|
||||
|
||||
// GeoDoubleParamsTag (optional)
|
||||
// Tag = 34736 (87BO.H)
|
||||
// Type = DOUBLE
|
||||
// Count = variable
|
||||
const val TAG_GEO_DOUBLE_PARAMS = 0x87b0
|
||||
|
||||
// GeoAsciiParamsTag (optional)
|
||||
// Tag = 34737 (87B1.H)
|
||||
// Type = ASCII
|
||||
// Count = variable
|
||||
val TAG_GEO_ASCII_PARAMS = 0x87b1
|
||||
|
||||
/*
|
||||
Photoshop
|
||||
https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/
|
||||
https://www.adobe.io/content/dam/udp/en/open/standards/tiff/TIFFphotoshop.pdf
|
||||
*/
|
||||
|
||||
// ImageSourceData
|
||||
// Tag = 37724 (935C.H)
|
||||
// Type = UNDEFINED
|
||||
val TAG_IMAGE_SOURCE_DATA = 0x935c
|
||||
|
||||
/*
|
||||
DNG
|
||||
https://www.adobe.com/content/dam/acom/en/products/photoshop/pdfs/dng_spec_1.4.0.0.pdf
|
||||
*/
|
||||
|
||||
// CameraSerialNumber
|
||||
// Tag = 50735 (C62F.H)
|
||||
// Type = ASCII
|
||||
// Count = variable
|
||||
val TAG_CAMERA_SERIAL_NUMBER = 0xc62f
|
||||
|
||||
// OriginalRawFileName (optional)
|
||||
// Tag = 50827 (C68B.H)
|
||||
// Type = ASCII or BYTE
|
||||
// Count = variable
|
||||
val TAG_ORIGINAL_RAW_FILE_NAME = 0xc68b
|
||||
|
||||
private val tagNameMap = hashMapOf(
|
||||
TAG_X_POSITION to "X Position",
|
||||
TAG_Y_POSITION to "Y Position",
|
||||
TAG_COLOR_MAP to "Color Map",
|
||||
TAG_EXTRA_SAMPLES to "Extra Samples",
|
||||
TAG_SAMPLE_FORMAT to "Sample Format",
|
||||
// SGI
|
||||
TAG_MATTEING to "Matteing",
|
||||
// GeoTIFF
|
||||
TAG_GEO_ASCII_PARAMS to "Geo Ascii Params",
|
||||
TAG_GEO_DOUBLE_PARAMS to "Geo Double Params",
|
||||
TAG_GEO_KEY_DIRECTORY to "Geo Key Directory",
|
||||
TAG_MODEL_PIXEL_SCALE to "Model Pixel Scale",
|
||||
TAG_MODEL_TIEPOINT to "Model Tiepoint",
|
||||
TAG_MODEL_TRANSFORMATION to "Model Transformation",
|
||||
// Photoshop
|
||||
TAG_IMAGE_SOURCE_DATA to "Image Source Data",
|
||||
// DNG
|
||||
TAG_CAMERA_SERIAL_NUMBER to "Camera Serial Number",
|
||||
TAG_ORIGINAL_RAW_FILE_NAME to "Original Raw File Name",
|
||||
)
|
||||
|
||||
fun getTagName(tag: Int): String? {
|
||||
return tagNameMap[tag]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue