-
Notifications
You must be signed in to change notification settings - Fork 136
Open
Description
Attempting to extract GPS metadata from an image known to contain it causes the following error to be logged:
loading EXIF sub-IFD: exif: sub-IFD ExifIFDPointer decode failed: zero length tag value
Go version:
go version go1.12.6 linux/amd64
Test code (basically copy-paste of sample):
package main
import (
"fmt"
"log"
"os"
"github.com/rwcarlsen/goexif/exif"
"github.com/rwcarlsen/goexif/mknote"
)
func main() {
fname := "osaka.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)
}
Image file: https://github.com/FooSoft/goldsmith-components/raw/master/plugins/exif/testdata/source/osaka.jpg
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels