diff --git a/internal/meta/exif.go b/internal/meta/exif.go index 2ff51688f..a540c783f 100644 --- a/internal/meta/exif.go +++ b/internal/meta/exif.go @@ -157,6 +157,15 @@ func Exif(filename string) (data Data, err error) { } if value, ok := tags["ExposureTime"]; ok { + if n := strings.Split(value, "/"); len(n) == 2 { + if n[0] != "1" && len(n[0]) < len(n[1]) { + n0, _ := strconv.ParseUint(n[0], 10, 64) + if n1, err := strconv.ParseUint(n[1], 10, 64); err == nil && n0 > 0 && n1 > 0 { + value = fmt.Sprintf("1/%d", n1 / n0) + } + } + } + data.Exposure = value } diff --git a/internal/meta/exif_test.go b/internal/meta/exif_test.go index 4c4b0e1a3..ab1efb73d 100644 --- a/internal/meta/exif_test.go +++ b/internal/meta/exif_test.go @@ -24,6 +24,7 @@ func TestExif(t *testing.T) { assert.Equal(t, float32(52.45969), data.Lat) assert.Equal(t, float32(13.321832), data.Lng) assert.Equal(t, 0, data.Altitude) + assert.Equal(t, "1/50", data.Exposure) assert.Equal(t, "HUAWEI", data.CameraMake) assert.Equal(t, "ELE-L29", data.CameraModel) assert.Equal(t, "", data.CameraOwner) @@ -56,6 +57,7 @@ func TestExif(t *testing.T) { assert.Equal(t, float32(51.254852), data.Lat) assert.Equal(t, float32(7.389468), data.Lng) assert.Equal(t, 0, data.Altitude) + assert.Equal(t, "1/125", data.Exposure) assert.Equal(t, "Canon", data.CameraMake) assert.Equal(t, "Canon EOS 50D", data.CameraModel) assert.Equal(t, "Thomas Meyer-Boudnik", data.CameraOwner) @@ -84,6 +86,7 @@ func TestExif(t *testing.T) { assert.Equal(t, 3840, data.Width) assert.Equal(t, float32(0), data.Lng) assert.Equal(t, 0, data.Altitude) + assert.Equal(t, "1/2462", data.Exposure) assert.Equal(t, "GoPro", data.CameraMake) assert.Equal(t, "HD2", data.CameraModel) assert.Equal(t, "", data.CameraOwner) @@ -110,6 +113,7 @@ func TestExif(t *testing.T) { assert.Equal(t, float32(34.79745), data.Lat) assert.Equal(t, float32(134.76463), data.Lng) assert.Equal(t, 0, data.Altitude) + assert.Equal(t, "1/4000", data.Exposure) assert.Equal(t, "Apple", data.CameraMake) assert.Equal(t, "iPhone 7", data.CameraModel) assert.Equal(t, 74, data.FocalLength)