From 6e4eb566187c5cea702ea9cc0124b1c00f560dcd Mon Sep 17 00:00:00 2001 From: Puneet Rai Date: Sun, 8 Feb 2026 13:19:52 +0530 Subject: [PATCH] fix(tiff): add missing tag names and value decoding Add proper names and enum decoding for standard TIFF 6.0 tags: - FillOrder (0x010A): Normal, Reversed - PageNumber (0x0129) - Predictor (0x013D): None, Horizontal differencing, Floating point - ExtraSamples (0x0152): Unspecified, Associated/Unassociated Alpha - SampleFormat (0x0153): Unsigned/Signed integer, IEEE float, Undefined Fixes #39 Co-Authored-By: Claude Opus 4.5 --- internal/parser/tiff/lookup.go | 5 +++ internal/parser/tiff/lookup_test.go | 5 +++ internal/parser/tiff/values.go | 28 +++++++++++++++ internal/parser/tiff/values_test.go | 56 +++++++++++++++++++++++++++++ 4 files changed, 94 insertions(+) diff --git a/internal/parser/tiff/lookup.go b/internal/parser/tiff/lookup.go index 2ae7448..07f202b 100644 --- a/internal/parser/tiff/lookup.go +++ b/internal/parser/tiff/lookup.go @@ -44,6 +44,7 @@ var tiffTagNames = map[uint16]string{ 0x0102: "BitsPerSample", 0x0103: "Compression", 0x0106: "PhotometricInterpretation", + 0x010A: "FillOrder", 0x010E: "ImageDescription", 0x010F: "Make", 0x0110: "Model", @@ -56,14 +57,18 @@ var tiffTagNames = map[uint16]string{ 0x011B: "YResolution", 0x011C: "PlanarConfiguration", 0x0128: "ResolutionUnit", + 0x0129: "PageNumber", 0x0131: "Software", 0x0132: "DateTime", 0x013B: "Artist", 0x013C: "HostComputer", + 0x013D: "Predictor", 0x013E: "WhitePoint", 0x013F: "PrimaryChromaticities", 0x0142: "TileWidth", 0x0143: "TileLength", + 0x0152: "ExtraSamples", + 0x0153: "SampleFormat", 0x0201: "JPEGInterchangeFormat", 0x0202: "JPEGInterchangeFormatLength", 0x0211: "YCbCrCoefficients", diff --git a/internal/parser/tiff/lookup_test.go b/internal/parser/tiff/lookup_test.go index d063566..abf4e71 100644 --- a/internal/parser/tiff/lookup_test.go +++ b/internal/parser/tiff/lookup_test.go @@ -22,6 +22,11 @@ func TestGetTIFFTagName(t *testing.T) { {"Software", 0x0131, "Software"}, {"DateTime", 0x0132, "DateTime"}, {"Artist", 0x013B, "Artist"}, + {"FillOrder", 0x010A, "FillOrder"}, + {"PageNumber", 0x0129, "PageNumber"}, + {"Predictor", 0x013D, "Predictor"}, + {"ExtraSamples", 0x0152, "ExtraSamples"}, + {"SampleFormat", 0x0153, "SampleFormat"}, {"Copyright", 0x8298, "Copyright"}, {"ExifIFDPointer", 0x8769, "ExifIFDPointer"}, {"GPSInfoIFDPointer", 0x8825, "GPSInfoIFDPointer"}, diff --git a/internal/parser/tiff/values.go b/internal/parser/tiff/values.go index b8e1f15..389baa0 100644 --- a/internal/parser/tiff/values.go +++ b/internal/parser/tiff/values.go @@ -134,6 +134,12 @@ var tiffEnumValues = map[uint16]map[uint16]string{ 2: "Planar", }, + // FillOrder (0x010A) + 0x010A: { + 1: "Normal", + 2: "Reversed", + }, + // ResolutionUnit (0x0128) 0x0128: { 1: "None", @@ -141,6 +147,28 @@ var tiffEnumValues = map[uint16]map[uint16]string{ 3: "centimeters", }, + // Predictor (0x013D) + 0x013D: { + 1: "None", + 2: "Horizontal differencing", + 3: "Floating point predictor", + }, + + // ExtraSamples (0x0152) + 0x0152: { + 0: "Unspecified", + 1: "Associated Alpha", + 2: "Unassociated Alpha", + }, + + // SampleFormat (0x0153) + 0x0153: { + 1: "Unsigned integer", + 2: "Signed integer", + 3: "IEEE floating point", + 4: "Undefined", + }, + // YCbCrPositioning (0x0213) 0x0213: { 1: "Centered", diff --git a/internal/parser/tiff/values_test.go b/internal/parser/tiff/values_test.go index 1b05e36..b99e228 100644 --- a/internal/parser/tiff/values_test.go +++ b/internal/parser/tiff/values_test.go @@ -60,6 +60,62 @@ func TestDecodeEnumValue(t *testing.T) { value: uint16(1), expected: "Centered", }, + { + name: "FillOrder Normal", + tag: 0x010A, + dirName: "IFD0", + value: uint16(1), + expected: "Normal", + }, + { + name: "FillOrder Reversed", + tag: 0x010A, + dirName: "IFD0", + value: uint16(2), + expected: "Reversed", + }, + { + name: "Predictor None", + tag: 0x013D, + dirName: "IFD0", + value: uint16(1), + expected: "None", + }, + { + name: "Predictor Horizontal differencing", + tag: 0x013D, + dirName: "IFD0", + value: uint16(2), + expected: "Horizontal differencing", + }, + { + name: "ExtraSamples Unspecified", + tag: 0x0152, + dirName: "IFD0", + value: uint16(0), + expected: "Unspecified", + }, + { + name: "ExtraSamples Associated Alpha", + tag: 0x0152, + dirName: "IFD0", + value: uint16(1), + expected: "Associated Alpha", + }, + { + name: "SampleFormat Unsigned integer", + tag: 0x0153, + dirName: "IFD0", + value: uint16(1), + expected: "Unsigned integer", + }, + { + name: "SampleFormat IEEE floating point", + tag: 0x0153, + dirName: "IFD0", + value: uint16(3), + expected: "IEEE floating point", + }, // EXIF tags {