nifuda

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2019 License: MIT Imports: 7 Imported by: 2

README

nifuda

GoDoc Go Report Card Build Status codecov

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

Documentation

Overview

Package nifuda implements reading of EXIF tags as defined in EXIF 2.31 specification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Exif

type Exif struct {
	Image ImageTags
	Photo PhotoTags
	Gps   GpsTags
}

Exif provides access to decoded EXIF tags.

func Read

func Read(rs io.ReadSeeker) (*Exif, error)

Read decode EXIF data from an io.ReadSeeker.

type GpsTags

type GpsTags struct {
	GPSVersionID         string
	GPSLatitudeRef       string
	GPSLatitude          string
	GPSLongitudeRef      string
	GPSLongitude         string
	GPSAltitudeRef       string
	GPSAltitude          float32
	GPSTimeStamp         string
	GPSSatellites        string
	GPSStatus            string
	GPSDOP               float32
	GPSMeasureMode       string
	GPSSpeedRef          string
	GPSSpeed             float32
	GPSTrackRef          string
	GPSTrack             float32
	GPSImgDirectionRef   string
	GPSImgDirection      float32
	GPSMapDatum          string
	GPSDestLatitudeRef   string
	GPSDestLatitude      string
	GPSDestLongitudeRef  string
	GPSDestLongitude     string
	GPSDestBearingRef    string
	GPSDestBearing       float32
	GPSDestDistanceRef   string
	GPSDestDistance      float32
	GPSDateStamp         string
	GPSDifferential      uint16
	GPSHPositioningError float32
}

GpsTags contains tags from GPS SubIFD. Fields are defined in order they appeared in chapter 4.6.6 of Exif 2.31

type ImageTags

type ImageTags struct {
	// A. Tags relating to image data structure
	ExifIFD             uint32
	GpsIFD              uint32
	InteroperabilityIFD uint32
	//ImageWidth SHORT or LONG :(
	//ImageLength SHORT or LONG :(
	BitsPerSample             uint16
	Compression               string
	PhotometricInterpretation string
	SamplesPerPixel           uint16
	PlanarConfiguration       string
	YCbCrPositioning          string
	ResolutionUnit            string
	// B. Tags relating to recording offset
	// C. Tags relating to image data characteristics
	// D. Other tags
	DateTime         string
	ImageDescription string
	Make             string
	Model            string
	Software         string
	Artist           string
	Copyright        string
}

ImageTags contains tags from first IFD (IFD0). Fields are defined in order they appeared in chapter 4.6.4 of Exif 2.31

type PhotoTags

type PhotoTags struct {
	// A. Tags Relating to Version
	ExifVersion     string
	FlashpixVersion string
	// B. Tag Relating to Image Data Characteristics
	// C. Tags Relating to Image Configuration
	// D. Tags Relating to User Information
	// E. Tag Relating to Related File Information
	// F. Tags Relating to Date and Time
	DateTimeOriginal    string
	DateTimeDigitized   string
	OffsetTime          string
	OffsetTimeOriginal  string
	OffsetTimeDigitized string
	SubSecTime          string
	SubSecTimeOriginal  string
	SubSecTimeDigitized string
	// G. Tags Relating to Picture-Taking Conditions
	ExposureProgram     string
	SpectralSensitivity string
	MeteringMode        string
}

PhotoTags contains tags from Exif SubIFD. Fields are defined in order they appeared in chapter 4.6.5 of Exif 2.31

Directories

Path Synopsis
internal
cmd/testjpeg
Create jpeg files mainly for error test cases Run with: go run testjpeg.go
Create jpeg files mainly for error test cases Run with: go run testjpeg.go
cmd/testtiff
Create tiff files mainly for error test cases Run with: go run testtiff.go
Create tiff files mainly for error test cases Run with: go run testtiff.go

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL