diff options
author | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
---|---|---|
committer | Jack <jackdeng@gmail.com> | 2015-09-22 08:16:51 -0700 |
commit | 602bed85f2b32733f73e2edddb542fa36baac462 (patch) | |
tree | 06a6ee9b609a9122bc2f0e6f6e6300f9ba79a3aa /Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go | |
parent | a31868336f97a91bfd5a7e91e99a9b294d131f90 (diff) | |
parent | f439c82d7c885b4c530ba9da0a41b17910743b55 (diff) | |
download | chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.gz chat-602bed85f2b32733f73e2edddb542fa36baac462.tar.bz2 chat-602bed85f2b32733f73e2edddb542fa36baac462.zip |
fix conflict
Diffstat (limited to 'Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go')
-rw-r--r-- | Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go b/Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go new file mode 100644 index 000000000..45fd5d4ad --- /dev/null +++ b/Godeps/_workspace/src/github.com/rwcarlsen/goexif/exif/example_test.go @@ -0,0 +1,42 @@ +package exif_test + +import ( + "fmt" + "log" + "os" + + "github.com/rwcarlsen/goexif/exif" + "github.com/rwcarlsen/goexif/mknote" +) + +func ExampleDecode() { + fname := "sample1.jpg" + + f, err := os.Open(fname) + if err != nil { + log.Fatal(err) + } + + // Optionally register camera makenote data parsing - currently Nikon and + // Canon are supported. + exif.RegisterParsers(mknote.All...) + + x, err := exif.Decode(f) + if err != nil { + log.Fatal(err) + } + + camModel, _ := x.Get(exif.Model) // normally, don't ignore errors! + fmt.Println(camModel.StringVal()) + + focal, _ := x.Get(exif.FocalLength) + numer, denom, _ := focal.Rat2(0) // retrieve first (only) rat. value + fmt.Printf("%v/%v", numer, denom) + + // Two convenience functions exist for date/time taken and GPS coords: + tm, _ := x.DateTime() + fmt.Println("Taken: ", tm) + + lat, long, _ := x.LatLong() + fmt.Println("lat, long: ", lat, ", ", long) +} |