/
info.go
41 lines (35 loc) 路 878 Bytes
/
info.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package operations
import (
"fmt"
"os"
"github.com/bernarpa/photo/config"
"github.com/bernarpa/photo/exiftool"
"github.com/rwcarlsen/goexif/exif"
"github.com/rwcarlsen/goexif/tiff"
)
// ShowHelpInfo prints the help for the info operation.
func ShowHelpInfo() {
fmt.Println()
fmt.Println("Usage: photo info [file]")
fmt.Println()
fmt.Println(" file photo or video file")
fmt.Println()
}
type infoWalker struct{}
func (infoWalker) Walk(name exif.FieldName, tag *tiff.Tag) error {
data, _ := tag.MarshalJSON()
fmt.Printf(" %s: %s\n", name, string(data))
return nil
}
// Info tries to print the metadata of the photo or video file.
func Info(conf *config.Config, target *config.Target) {
var fileName string
if len(os.Args) == 3 {
fileName = os.Args[2]
} else {
ShowHelpInfo()
return
}
et := exiftool.Create(conf.Perl)
et.Dump(fileName)
}