exif: Return the proper exposure time value in some special cases

Return value in float64 if exposure time is int or greater than 1, otherwise return in fraction.

Fixes #10738
This commit is contained in:
WaltCuller
2023-02-26 18:19:49 +08:00
committed by GitHub
parent ce524d0b5e
commit 39cc3a2a7e
15 changed files with 184 additions and 3 deletions

View File

@@ -173,11 +173,12 @@ func decodeTag(x *_exif.Exif, f _exif.FieldName, t *tiff.Tag) (any, error) {
case tiff.RatVal:
n, d, _ := t.Rat2(i)
rat := big.NewRat(n, d)
if n == 1 {
rv = append(rv, rat)
} else {
// if t is int or t > 1, use float64
if rat.IsInt() || rat.Cmp(big.NewRat(1, 1)) == 1 {
f, _ := rat.Float64()
rv = append(rv, f)
} else {
rv = append(rv, rat)
}
case tiff.FloatVal: