Skip to content

Commit 9338d33

Browse files
rpuneetclaude
andauthored
fix(tiff): add missing tag names and value decoding (#40)
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 <[email protected]>
1 parent d996fd1 commit 9338d33

File tree

4 files changed

+94
-0
lines changed

4 files changed

+94
-0
lines changed

internal/parser/tiff/lookup.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ var tiffTagNames = map[uint16]string{
4444
0x0102: "BitsPerSample",
4545
0x0103: "Compression",
4646
0x0106: "PhotometricInterpretation",
47+
0x010A: "FillOrder",
4748
0x010E: "ImageDescription",
4849
0x010F: "Make",
4950
0x0110: "Model",
@@ -56,14 +57,18 @@ var tiffTagNames = map[uint16]string{
5657
0x011B: "YResolution",
5758
0x011C: "PlanarConfiguration",
5859
0x0128: "ResolutionUnit",
60+
0x0129: "PageNumber",
5961
0x0131: "Software",
6062
0x0132: "DateTime",
6163
0x013B: "Artist",
6264
0x013C: "HostComputer",
65+
0x013D: "Predictor",
6366
0x013E: "WhitePoint",
6467
0x013F: "PrimaryChromaticities",
6568
0x0142: "TileWidth",
6669
0x0143: "TileLength",
70+
0x0152: "ExtraSamples",
71+
0x0153: "SampleFormat",
6772
0x0201: "JPEGInterchangeFormat",
6873
0x0202: "JPEGInterchangeFormatLength",
6974
0x0211: "YCbCrCoefficients",

internal/parser/tiff/lookup_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ func TestGetTIFFTagName(t *testing.T) {
2222
{"Software", 0x0131, "Software"},
2323
{"DateTime", 0x0132, "DateTime"},
2424
{"Artist", 0x013B, "Artist"},
25+
{"FillOrder", 0x010A, "FillOrder"},
26+
{"PageNumber", 0x0129, "PageNumber"},
27+
{"Predictor", 0x013D, "Predictor"},
28+
{"ExtraSamples", 0x0152, "ExtraSamples"},
29+
{"SampleFormat", 0x0153, "SampleFormat"},
2530
{"Copyright", 0x8298, "Copyright"},
2631
{"ExifIFDPointer", 0x8769, "ExifIFDPointer"},
2732
{"GPSInfoIFDPointer", 0x8825, "GPSInfoIFDPointer"},

internal/parser/tiff/values.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,41 @@ var tiffEnumValues = map[uint16]map[uint16]string{
134134
2: "Planar",
135135
},
136136

137+
// FillOrder (0x010A)
138+
0x010A: {
139+
1: "Normal",
140+
2: "Reversed",
141+
},
142+
137143
// ResolutionUnit (0x0128)
138144
0x0128: {
139145
1: "None",
140146
2: "inches",
141147
3: "centimeters",
142148
},
143149

150+
// Predictor (0x013D)
151+
0x013D: {
152+
1: "None",
153+
2: "Horizontal differencing",
154+
3: "Floating point predictor",
155+
},
156+
157+
// ExtraSamples (0x0152)
158+
0x0152: {
159+
0: "Unspecified",
160+
1: "Associated Alpha",
161+
2: "Unassociated Alpha",
162+
},
163+
164+
// SampleFormat (0x0153)
165+
0x0153: {
166+
1: "Unsigned integer",
167+
2: "Signed integer",
168+
3: "IEEE floating point",
169+
4: "Undefined",
170+
},
171+
144172
// YCbCrPositioning (0x0213)
145173
0x0213: {
146174
1: "Centered",

internal/parser/tiff/values_test.go

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,62 @@ func TestDecodeEnumValue(t *testing.T) {
6060
value: uint16(1),
6161
expected: "Centered",
6262
},
63+
{
64+
name: "FillOrder Normal",
65+
tag: 0x010A,
66+
dirName: "IFD0",
67+
value: uint16(1),
68+
expected: "Normal",
69+
},
70+
{
71+
name: "FillOrder Reversed",
72+
tag: 0x010A,
73+
dirName: "IFD0",
74+
value: uint16(2),
75+
expected: "Reversed",
76+
},
77+
{
78+
name: "Predictor None",
79+
tag: 0x013D,
80+
dirName: "IFD0",
81+
value: uint16(1),
82+
expected: "None",
83+
},
84+
{
85+
name: "Predictor Horizontal differencing",
86+
tag: 0x013D,
87+
dirName: "IFD0",
88+
value: uint16(2),
89+
expected: "Horizontal differencing",
90+
},
91+
{
92+
name: "ExtraSamples Unspecified",
93+
tag: 0x0152,
94+
dirName: "IFD0",
95+
value: uint16(0),
96+
expected: "Unspecified",
97+
},
98+
{
99+
name: "ExtraSamples Associated Alpha",
100+
tag: 0x0152,
101+
dirName: "IFD0",
102+
value: uint16(1),
103+
expected: "Associated Alpha",
104+
},
105+
{
106+
name: "SampleFormat Unsigned integer",
107+
tag: 0x0153,
108+
dirName: "IFD0",
109+
value: uint16(1),
110+
expected: "Unsigned integer",
111+
},
112+
{
113+
name: "SampleFormat IEEE floating point",
114+
tag: 0x0153,
115+
dirName: "IFD0",
116+
value: uint16(3),
117+
expected: "IEEE floating point",
118+
},
63119

64120
// EXIF tags
65121
{

0 commit comments

Comments
 (0)