From 075bb2f07cafc99a8898a8ebddfe1b1ba5c25f48 Mon Sep 17 00:00:00 2001 From: Thibault Deckers Date: Thu, 7 Jan 2021 15:54:15 +0900 Subject: [PATCH] metadata: added some TIFF tag names --- .../aves/channel/calls/MetadataHandler.kt | 2 +- .../deckers/thibault/aves/metadata/Geotiff.kt | 52 ------- .../aves/metadata/MetadataExtractorHelper.kt | 8 +- .../thibault/aves/metadata/TiffTags.kt | 138 ++++++++++++++++++ 4 files changed, 143 insertions(+), 57 deletions(-) delete mode 100644 android/app/src/main/kotlin/deckers/thibault/aves/metadata/Geotiff.kt create mode 100644 android/app/src/main/kotlin/deckers/thibault/aves/metadata/TiffTags.kt diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataHandler.kt b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataHandler.kt index 33fc09a69..ad72db45f 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataHandler.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/channel/calls/MetadataHandler.kt @@ -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) }) diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Geotiff.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Geotiff.kt deleted file mode 100644 index 28a09ef25..000000000 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/Geotiff.kt +++ /dev/null @@ -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] - } -} \ No newline at end of file diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/MetadataExtractorHelper.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/MetadataExtractorHelper.kt index 74c63bf4a..18b23f6d8 100644 --- a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/MetadataExtractorHelper.kt +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/MetadataExtractorHelper.kt @@ -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 diff --git a/android/app/src/main/kotlin/deckers/thibault/aves/metadata/TiffTags.kt b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/TiffTags.kt new file mode 100644 index 000000000..0f6dce703 --- /dev/null +++ b/android/app/src/main/kotlin/deckers/thibault/aves/metadata/TiffTags.kt @@ -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] + } +} \ No newline at end of file