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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
|
goexif
======
[](https://godoc.org/github.com/rwcarlsen/goexif)
Provides decoding of basic exif and tiff encoded data. Still in alpha - no guarantees.
Suggestions and pull requests are welcome. Functionality is split into two packages - "exif" and "tiff"
The exif package depends on the tiff package.
Like goexif? - Bitcoin Cash tips welcome: 1DrU5V37nTXuv4vnRLVpahJEjhdATNgoBh
To install, in a terminal type:
```
go get github.com/rwcarlsen/goexif/exif
```
Or if you just want the tiff package:
```
go get github.com/rwcarlsen/goexif/tiff
```
Example usage:
```go
package main
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)
}
```
<!--golang-->
[](http://githalytics.com/rwcarlsen/goexif)
|