Documentation ¶
Overview ¶
Package exif implements decoding of EXIF data as defined in the EXIF 2.2 specification.
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Exif ¶
type Exif struct {
// contains filtered or unexported fields
}
func Decode ¶
Decode parses EXIF-encoded data from r and returns a queryable Exif object.
Example ¶
package main import ( "fmt" "log" "os" "camlistore.org/third_party/github.com/camlistore/goexif/exif" ) func main() { fname := "sample1.jpg" f, err := os.Open(fname) if err != nil { log.Fatal(err) } x, err := exif.Decode(f) if err != nil { log.Fatal(err) } camModel, _ := x.Get("Model") date, _ := x.Get("DateTimeOriginal") fmt.Println(camModel.StringVal()) fmt.Println(date.StringVal()) focal, _ := x.Get("FocalLength") numer, denom := focal.Rat2(0) // retrieve first (only) rat. value fmt.Printf("%v/%v", numer, denom) }
Output:
func (*Exif) DateTime ¶
DateTime returns the EXIF's "DateTimeOriginal" field, which is the creation time of the photo. If not found, it tries the "DateTime" (which is meant as the modtime) instead. The error will be TagNotPresentErr if none of those tags were found, or a generic error if the tag value was not a string, or the error returned by time.Parse.
func (*Exif) Get ¶
Get retrieves the EXIF tag for the given field name.
If the tag is not known or not present, an error is returned. If the tag name is known, the error will be a TagNotPresentError.
func (Exif) MarshalJSON ¶
type TagNotPresentError ¶
type TagNotPresentError FieldName
A TagNotPresentError is returned when the requested field is not present in the EXIF.
func (TagNotPresentError) Error ¶
func (tag TagNotPresentError) Error() string