Medium/goexif

Name: goexif

Owner: Medium

Description: Decode embedded EXIF meta data from image files.

Forked from: rwcarlsen/goexif

Created: 2017-01-03 21:38:36.0

Updated: 2018-02-28 10:32:40.0

Pushed: 2017-01-03 22:45:08.0

Homepage:

Size: 1081

Language: Go

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

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. Documentation can be found at http://godoc.org/github.com/rwcarlsen/goexif

Like goexif? - Bitcoin tips welcome: 17M7LFh3ETz4bz83VikB7xuGQskt8K5Lj4

To install, in a terminal type:

et github.com/rwcarlsen/goexif/exif

Or if you just want the tiff package:

et github.com/rwcarlsen/goexif/tiff

Example usage:

age main

rt (
"fmt"
"log"
"os"

"github.com/rwcarlsen/goexif/exif"
"github.com/rwcarlsen/goexif/mknote"


 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)

githalytics.com alpha


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.