• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..03-May-2022-

exif/H03-May-2022-

exifstat/H01-Apr-2019-

mknote/H01-Apr-2019-

tiff/H03-May-2022-

.gitignoreH A D01-Apr-2019258

LICENSEH A D01-Apr-20191.3 KiB

README.mdH A D01-Apr-20191.7 KiB

README.md

1goexif
2======
3
4[![GoDoc](https://godoc.org/github.com/rwcarlsen/goexif?status.svg)](https://godoc.org/github.com/rwcarlsen/goexif)
5
6Provides decoding of basic exif and tiff encoded data. Still in alpha - no guarantees.
7Suggestions and pull requests are welcome.  Functionality is split into two packages - "exif" and "tiff"
8The exif package depends on the tiff package.
9
10Like goexif? - Bitcoin Cash tips welcome: 1DrU5V37nTXuv4vnRLVpahJEjhdATNgoBh
11
12To install, in a terminal type:
13
14```
15go get github.com/rwcarlsen/goexif/exif
16```
17
18Or if you just want the tiff package:
19
20```
21go get github.com/rwcarlsen/goexif/tiff
22```
23
24Example usage:
25
26```go
27package main
28
29import (
30	"fmt"
31	"log"
32	"os"
33
34	"github.com/rwcarlsen/goexif/exif"
35	"github.com/rwcarlsen/goexif/mknote"
36)
37
38func ExampleDecode() {
39	fname := "sample1.jpg"
40
41	f, err := os.Open(fname)
42	if err != nil {
43		log.Fatal(err)
44	}
45
46	// Optionally register camera makenote data parsing - currently Nikon and
47	// Canon are supported.
48	exif.RegisterParsers(mknote.All...)
49
50	x, err := exif.Decode(f)
51	if err != nil {
52		log.Fatal(err)
53	}
54
55	camModel, _ := x.Get(exif.Model) // normally, don't ignore errors!
56	fmt.Println(camModel.StringVal())
57
58	focal, _ := x.Get(exif.FocalLength)
59	numer, denom, _ := focal.Rat2(0) // retrieve first (only) rat. value
60	fmt.Printf("%v/%v", numer, denom)
61
62	// Two convenience functions exist for date/time taken and GPS coords:
63	tm, _ := x.DateTime()
64	fmt.Println("Taken: ", tm)
65
66	lat, long, _ := x.LatLong()
67	fmt.Println("lat, long: ", lat, ", ", long)
68}
69```
70
71<!--golang-->
72[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/5e166f74cdb82b999ccd84e3c4dc4348 "githalytics.com")](http://githalytics.com/rwcarlsen/goexif)
73