Skip to content

Commit dae2c42

Browse files
committed
Merge origin/main - resolve FlashpixVersion format conflict
- Keep UserComment as decoded string (Bug #19) - Keep MakerNote parsed into Canon directory - Accept FlashpixVersion as string '0100' (PR #26)
2 parents 3dc6108 + f74796b commit dae2c42

File tree

3 files changed

+21
-7
lines changed

3 files changed

+21
-7
lines changed

api_integration_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,14 @@ func TestIntegration_JPEG(t *testing.T) {
2525
{Name: "CustomRendered", Value: "Portrait HDR"},
2626
{Name: "DateTimeDigitized", Value: "2019:09:21 14:43:51"},
2727
{Name: "DateTimeOriginal", Value: "2019:09:21 14:43:51"},
28-
{Name: "ExifVersion", Value: []byte{48, 50, 50, 49}},
28+
{Name: "ExifVersion", Value: "0221"},
2929
{Name: "ExposureBiasValue", Value: "0/1"},
3030
{Name: "ExposureMode", Value: "Auto"},
3131
{Name: "ExposureProgram", Value: "Program AE"},
3232
{Name: "ExposureTime", Value: "1/758"},
3333
{Name: "FNumber", Value: "9/5"},
3434
{Name: "Flash", Value: "Auto, Did not fire"},
35-
{Name: "FlashpixVersion", Value: []byte{48, 49, 48, 48}},
35+
{Name: "FlashpixVersion", Value: "0100"},
3636
{Name: "FocalLength", Value: "17/4"},
3737
{Name: "FocalLengthIn35mmFilm", Value: uint16(26)},
3838
{Name: "ISOSpeedRatings", Value: uint16(32)},
@@ -272,7 +272,7 @@ func TestIntegration_CR2(t *testing.T) {
272272
{Name: "FNumber", Value: "14/10"},
273273
{Name: "ExposureProgram", Value: "Program AE"},
274274
{Name: "ISOSpeedRatings", Value: uint16(640)},
275-
{Name: "ExifVersion", Value: []byte{48, 50, 50, 49}}, // "0221" in hex
275+
{Name: "ExifVersion", Value: "0221"},
276276
{Name: "DateTimeOriginal", Value: "2004:11:13 23:02:21"},
277277
{Name: "DateTimeDigitized", Value: "2004:11:13 23:02:21"},
278278
{Name: "ComponentsConfiguration", Value: []byte{1, 2, 3, 0}}, // Y, Cb, Cr, -
@@ -284,7 +284,7 @@ func TestIntegration_CR2(t *testing.T) {
284284
{Name: "FocalLength", Value: "85/1"},
285285
// MakerNote is now parsed into Canon directory (see below)
286286
{Name: "UserComment", Type: "string"}, // Decoded comment text
287-
{Name: "FlashpixVersion", Value: []byte{48, 49, 48, 48}}, // "0100" in hex
287+
{Name: "FlashpixVersion", Value: "0100"},
288288
{Name: "ColorSpace", Value: "sRGB"},
289289
{Name: "PixelXDimension", Value: uint16(4992)},
290290
{Name: "PixelYDimension", Value: uint16(3328)},

internal/parser/tiff/constants.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ const (
3939
bufferSizeUint64 = 8
4040

4141
// Special tag values
42-
tagGPSVersionID = 0x0000 // GPS Version ID tag
42+
tagGPSVersionID = 0x0000 // GPS Version ID tag
43+
tagExifVersion = 0x9000 // EXIF Version tag
44+
tagFlashpixVersion = 0xA000 // Flashpix Version tag
45+
tagInteropVersion = 0x0002 // Interoperability Version tag
4346

4447
// Byte order markers
4548
byteOrderLittleEndian = 'I'

internal/parser/tiff/ifd.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,11 +118,22 @@ func (p *Parser) parseTag(r *imxbin.Reader, entry *IFDEntry, dirName string) (*p
118118
return nil, err
119119
}
120120

121-
// Special formatting for GPS Version ID
122-
if entry.Tag == tagGPSVersionID && strings.ToLower(dirName) == "gps" {
121+
// Special formatting for version tags
122+
switch {
123+
case entry.Tag == tagGPSVersionID && strings.ToLower(dirName) == "gps":
123124
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
124125
value = fmt.Sprintf("%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3])
125126
}
127+
case entry.Tag == tagExifVersion || entry.Tag == tagFlashpixVersion:
128+
// ExifVersion/FlashpixVersion are stored as 4 ASCII bytes (e.g., "0230" for 2.30)
129+
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
130+
value = string(bytes)
131+
}
132+
case entry.Tag == tagInteropVersion && strings.ToLower(dirName) == "interoperability":
133+
// InteroperabilityVersion is also stored as 4 ASCII bytes
134+
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
135+
value = string(bytes)
136+
}
126137
}
127138

128139
// Decode UserComment (EXIF tag 0x9286)

0 commit comments

Comments
 (0)