Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions api_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,14 @@ func TestIntegration_JPEG(t *testing.T) {
{Name: "CustomRendered", Value: "Portrait HDR"},
{Name: "DateTimeDigitized", Value: "2019:09:21 14:43:51"},
{Name: "DateTimeOriginal", Value: "2019:09:21 14:43:51"},
{Name: "ExifVersion", Value: []byte{48, 50, 50, 49}},
{Name: "ExifVersion", Value: "0221"},
{Name: "ExposureBiasValue", Value: "0/1"},
{Name: "ExposureMode", Value: "Auto"},
{Name: "ExposureProgram", Value: "Program AE"},
{Name: "ExposureTime", Value: "1/758"},
{Name: "FNumber", Value: "9/5"},
{Name: "Flash", Value: "Auto, Did not fire"},
{Name: "FlashpixVersion", Value: []byte{48, 49, 48, 48}},
{Name: "FlashpixVersion", Value: "0100"},
{Name: "FocalLength", Value: "17/4"},
{Name: "FocalLengthIn35mmFilm", Value: uint16(26)},
{Name: "ISOSpeedRatings", Value: uint16(32)},
Expand Down Expand Up @@ -272,7 +272,7 @@ func TestIntegration_CR2(t *testing.T) {
{Name: "FNumber", Value: "14/10"},
{Name: "ExposureProgram", Value: "Program AE"},
{Name: "ISOSpeedRatings", Value: uint16(640)},
{Name: "ExifVersion", Value: []byte{48, 50, 50, 49}}, // "0221" in hex
{Name: "ExifVersion", Value: "0221"},
{Name: "DateTimeOriginal", Value: "2004:11:13 23:02:21"},
{Name: "DateTimeDigitized", Value: "2004:11:13 23:02:21"},
{Name: "ComponentsConfiguration", Value: []byte{1, 2, 3, 0}}, // Y, Cb, Cr, -
Expand All @@ -284,7 +284,7 @@ func TestIntegration_CR2(t *testing.T) {
{Name: "FocalLength", Value: "85/1"},
{Name: "MakerNote", Type: "[]byte"}, // Binary data - check presence only
{Name: "UserComment", Type: "[]byte"}, // Binary data - check presence only
{Name: "FlashpixVersion", Value: []byte{48, 49, 48, 48}}, // "0100" in hex
{Name: "FlashpixVersion", Value: "0100"},
{Name: "ColorSpace", Value: "sRGB"},
{Name: "PixelXDimension", Value: uint16(4992)},
{Name: "PixelYDimension", Value: uint16(3328)},
Expand Down
5 changes: 4 additions & 1 deletion internal/parser/tiff/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@ const (
bufferSizeUint64 = 8

// Special tag values
tagGPSVersionID = 0x0000 // GPS Version ID tag
tagGPSVersionID = 0x0000 // GPS Version ID tag
tagExifVersion = 0x9000 // EXIF Version tag
tagFlashpixVersion = 0xA000 // Flashpix Version tag
tagInteropVersion = 0x0002 // Interoperability Version tag

// Byte order markers
byteOrderLittleEndian = 'I'
Expand Down
15 changes: 13 additions & 2 deletions internal/parser/tiff/ifd.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,22 @@ func (p *Parser) parseTag(r *imxbin.Reader, entry *IFDEntry, dirName string) (*p
return nil, err
}

// Special formatting for GPS Version ID
if entry.Tag == tagGPSVersionID && strings.ToLower(dirName) == "gps" {
// Special formatting for version tags
switch {
case entry.Tag == tagGPSVersionID && strings.ToLower(dirName) == "gps":
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
value = fmt.Sprintf("%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3])
}
case entry.Tag == tagExifVersion || entry.Tag == tagFlashpixVersion:
// ExifVersion/FlashpixVersion are stored as 4 ASCII bytes (e.g., "0230" for 2.30)
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
value = string(bytes)
}
case entry.Tag == tagInteropVersion && strings.ToLower(dirName) == "interoperability":
// InteroperabilityVersion is also stored as 4 ASCII bytes
if bytes, ok := value.([]byte); ok && len(bytes) == 4 {
value = string(bytes)
}
}

// Decode enum values to human-readable strings
Expand Down
Loading