• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

cshum / imagor / 15233893740

25 May 2025 03:47AM UTC coverage: 92.118% (+2.4%) from 89.678%
15233893740

Pull #544

github

cshum
update exif extraction
Pull Request #544: feat: introducing vipsgen

308 of 346 new or added lines in 6 files covered. (89.02%)

6 existing lines in 1 file now uncovered.

4862 of 5278 relevant lines covered (92.12%)

1.1 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

88.46
/processor/vipsprocessor/exif.go
1
package vipsprocessor
2

3
import "C"
4
import (
5
        "strconv"
6
        "strings"
7
)
8

9
// exifNames to extract, true to cast as int
10
var exifNames = map[string]bool{
11
        "Orientation":              true,
12
        "ResolutionUnit":           true,
13
        "FocalPlaneResolutionUnit": true,
14
        "YCbCrPositioning":         true,
15
        "Compression":              true,
16
        "exifExposureProgram":      true,
17
        "ISOSpeedRatings":          true,
18
        "MeteringMode":             true,
19
        "Flash":                    true,
20
        "ColorSpace":               true,
21
        "PixelXDimension":          true,
22
        "PixelYDimension":          true,
23
        "SensingMethod":            true,
24
        "ExposureMode":             true,
25
        "WhiteBalance":             true,
26
        "FocalLengthIn35mmFilm":    true,
27
        "SceneCaptureType":         true,
28
}
29

30
func exifStringShort(s string) string {
1✔
31
        i := strings.Index(s, " (")
1✔
32
        if i > -1 {
2✔
33
                return s[:i]
1✔
34
        }
1✔
NEW
35
        return s
×
36
}
37

38
func extractExif(rawExif map[string]string) map[string]any {
1✔
39
        var exif = map[string]any{}
1✔
40
        for tag, value := range rawExif {
2✔
41
                if len(tag) < 10 {
2✔
42
                        continue
1✔
43
                }
44
                name := tag[10:]
1✔
45
                value = strings.TrimSpace(exifStringShort(value))
1✔
46
                if value == "" {
2✔
47
                        continue
1✔
48
                }
49
                if exifNames[name] {
2✔
50
                        val, err := strconv.Atoi(value)
1✔
51
                        if err == nil {
2✔
52
                                exif[name] = val
1✔
53
                        } else {
1✔
NEW
54
                                exif[name] = value
×
NEW
55
                        }
×
56
                } else {
1✔
57
                        exif[name] = value
1✔
58
                }
1✔
59
        }
60
        return exif
1✔
61
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc