vinymeuh / nifuda

A Go library for reading EXIF tags from image files

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

nifuda

GoDoc License: MIT Release Build Status codecov Go Report Card

nifuda provides a native Go library to read tags from EXIF image files.

Getting Started

As a example, a very simplistic EXIF reader:

package main

import (
    "fmt"
    "log"
    "os"
    "reflect"

    "github.com/vinymeuh/nifuda"
)

func main() {
    if len(os.Args) != 2 {
        log.Fatalf("Usage: %s EXIF_FILE", os.Args[0])
    }

    f, err := os.Open(os.Args[1])
    if err != nil {
        log.Fatal(err)
    }
    defer f.Close()

    x, err := nifuda.Read(f)
    if err != nil {
        log.Fatal(err)
    }

    v := reflect.ValueOf(x.Image)
    vt := v.Type()
    for i := 0; i < vt.NumField(); i++ {
        fmt.Printf("Image.%-30s   %v\n", vt.Field(i).Name, v.Field(i).Interface())
    }

    v = reflect.ValueOf(x.Photo)
    vt = v.Type()
    for i := 0; i < vt.NumField(); i++ {
        fmt.Printf("Photo.%-30s   %v\n", vt.Field(i).Name, v.Field(i).Interface())
    }
}

More examples are availables in nf-tools repository.

References

Exif

TIFF

About

A Go library for reading EXIF tags from image files

License:MIT License


Languages

Language:Go 98.3%Language:Makefile 1.7%