exif

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: May 29, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package exif provides functions for parsing and extracting Exif Information.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrGpsCoordsNotValid means that some part of the geographic data were unparseable.
	ErrGpsCoordsNotValid = errors.New("error GPS coordinates not valid")
	// ErrGPSRationalNotValid means that the rawCoordinates were not long enough.
	ErrGPSRationalNotValid = errors.New("error GPS Coords requires a raw-coordinate with exactly three rationals")
)
View Source
var (
	// Alias to meta Errors
	ErrInvalidHeader = meta.ErrInvalidHeader
	ErrNoExif        = meta.ErrNoExif
	ErrEmptyTag      = errors.New("error empty tag")
)

Errors

View Source
var (
	ErrParseBufSize   = errors.New("error parse has insufficient data")
	ErrParseGPS       = errors.New("error parsing GPS coords")
	ErrParseTimeStamp = errors.New("error parsing timestamp")
	ErrParseSubSecond = errors.New("error parsing sub second")
	ErrParseRationals = errors.New("error parsing rationals")
)

Parsing Errors

View Source
var (
	ErrNikonMkNote = errors.New("error makernote is not a Nikon makernote")
)

Errors

View Source
var (
	ErrReadNegativeOffset = errors.New("error read at negative offset")
)

reader errors

View Source
var (
	InfoLogger *log.Logger
)

Functions

func NikonMkNoteHeader

func NikonMkNoteHeader(reader io.Reader) (byteOrder binary.ByteOrder, err error)

NikonMkNoteHeader parses the Nikon Makernote from reader and returns byteOrder and error

Types

type Data

type Data struct {
	// contains filtered or unexported fields
}

Data struct contains parsed Exif information

func ParseExif

func ParseExif(r io.ReaderAt, header meta.ExifHeader) (*Data, error)

ParseExif parses Exif metadata from an io.ReaderAt and a TiffHeader

If the header is invalid ParseExif will return ErrInvalidHeader.

func (*Data) Aperture

func (e *Data) Aperture() (meta.Aperture, error)

Aperture convenience func. "IFD/Exif" FNumber

func (*Data) Artist

func (e *Data) Artist() (artist string, err error)

Artist convenience func. "IFD" Artist

func (*Data) CameraMake

func (e *Data) CameraMake() (make string)

CameraMake convenience func. "IFD" Make

func (*Data) CameraModel

func (e *Data) CameraModel() (model string)

CameraModel convenience func. "IFD" Model

func (*Data) CameraSerial

func (e *Data) CameraSerial() (serial string, err error)

CameraSerial convenience func. "IFD/Exif" BodySerialNumber

func (*Data) CanonAFInfo

func (e *Data) CanonAFInfo() (afInfo canon.AFInfo, err error)

CanonAFInfo - Canon Camera AutoFocus Information from the Makernote

func (*Data) CanonCameraSettings

func (e *Data) CanonCameraSettings() (canon.CameraSettings, error)

CanonCameraSettings convenience func. "IFD/Exif/Makernotes.Canon" CanonCameraSettings Canon Camera Settings from the Makernote

func (*Data) CanonFileInfo

func (e *Data) CanonFileInfo() (canon.FileInfo, error)

CanonFileInfo convenience func. "IFD/Exif/Makernotes.Canon" CanonFileInfo Canon Camera File Info from the Makernote

func (*Data) CanonShotInfo

func (e *Data) CanonShotInfo() (canon.ShotInfo, error)

CanonShotInfo convenience func. "IFD/Exif/Makernotes.Canon" CanonShotInfo Canon Camera Shot Info from the Makernote

func (*Data) Copyright

func (e *Data) Copyright() (copyright string, err error)

Copyright convenience func. "IFD" Copyright

func (*Data) DateTime

func (e *Data) DateTime(tz *time.Location) (tm time.Time, err error)

DateTime returns a time.Time that corresponds with when it was created. Since EXIF data does not contain any timezone information, you should select a timezone using tz. If tz is nil UTC is assumed.

func (*Data) DebugJSON

func (e *Data) DebugJSON() ([]byte, error)

DebugJSON implements the JSONMarshaler interface that is used by encoding/json This is used primarily for testing and debuging.

func (*Data) Dimensions

func (e *Data) Dimensions() (dimensions meta.Dimensions)

Dimensions convenience func. "IFD" Dimensions

func (*Data) ExposureBias

func (e *Data) ExposureBias() (meta.ExposureBias, error)

ExposureBias convenience func. "IFD/Exif" ExposureBiasValue TODO: Add ExposureBias Function (Incomplete)

func (*Data) ExposureMode

func (e *Data) ExposureMode() (meta.ExposureMode, error)

ExposureMode convenience func. "IFD/Exif" ExposureMode

func (*Data) ExposureProgram

func (e *Data) ExposureProgram() (meta.ExposureProgram, error)

ExposureProgram convenience func. "IFD/Exif" ExposureProgram

func (*Data) ExposureValue

func (e *Data) ExposureValue() (ev float32, err error)

ExposureValue convenience func. "IFD/Exif" ShutterSpeedValue

func (*Data) Flash

func (e *Data) Flash() (meta.Flash, error)

Flash convenience func. "IFD/Exif" Flash

func (*Data) FocalLength

func (e *Data) FocalLength() (fl meta.FocalLength, err error)

FocalLength convenience func. "IFD/Exif" FocalLength Lens Focal Length in mm

func (*Data) FocalLengthIn35mmFilm

func (e *Data) FocalLengthIn35mmFilm() (fl meta.FocalLength, err error)

FocalLengthIn35mmFilm convenience func. "IFD/Exif" FocalLengthIn35mmFilm Lens Focal Length Equivalent for 35mm sensor in mm

func (*Data) GPSAltitude

func (e *Data) GPSAltitude() (alt float32, err error)

GPSAltitude convenience func. for "IFD/GPS" GPSAltitude and GPSAltitudeRef. Altitude is expressed as one RATIONAL value. The reference unit is meters.

func (*Data) GPSCellID

func (e *Data) GPSCellID() (cellID s2.CellID, err error)

GPSCellID returns the S2 cellID of the geographic location on the earth. A convenience func. that retrieves "IFD/GPS" GPSLatitude and GPSLongitude and converts them into an S2 CellID and returns the CellID.

If the CellID is not valid it returns ErrGpsCoordsNotValid.

func (*Data) GPSCoords

func (e *Data) GPSCoords() (lat float64, lng float64, err error)

GPSCoords is a convenience func. that retrieves "IFD/GPS" GPSLatitude and GPSLongitude

func (*Data) GPSDate

func (e *Data) GPSDate(tz *time.Location) (t time.Time, err error)

GPSDate convenience func. for "IFD/GPS" GPSDateStamp and GPSTimeStamp. Indicates the time as UTC (Coordinated Universal Time). Optionally sets subsecond based on "IFD/Exif" SubSecTimeOriginal. Sets time zone to time.UTC if non-provided.

func (*Data) GetTag

func (e *Data) GetTag(ifd ifds.IfdType, ifdIndex uint8, tagID tag.ID) (tag.Tag, error)

GetTag returns a tag from Exif and returns an error if tag doesn't exist

func (*Data) GetTagValue

func (e *Data) GetTagValue(t tag.Tag) (value interface{})

GetTagValue returns the tag's value as an interface.

For performance reasons its preferable to use the Parse* functions.

func (*Data) ISOSpeed

func (e *Data) ISOSpeed() (iso uint32, err error)

ISOSpeed convenience func. "IFD/Exif" ISOSpeed

func (*Data) ImageHeight

func (e *Data) ImageHeight() uint16

ImageHeight retturns the main image height

func (*Data) ImageWidth

func (e *Data) ImageWidth() uint16

ImageWidth returns the main image width

func (*Data) LensMake

func (e *Data) LensMake() (make string, err error)

LensMake convenience func. "IFD/Exif" LensMake

func (*Data) LensModel

func (e *Data) LensModel() (model string, err error)

LensModel convenience func. "IFD/Exif" LensModel

func (*Data) LensSerial

func (e *Data) LensSerial() (serial string, err error)

LensSerial convenience func. "IFD/Exif" LensSerialNumber

func (*Data) MeteringMode

func (e *Data) MeteringMode() (meta.MeteringMode, error)

MeteringMode convenience func. "IFD/Exif" MeteringMode

func (*Data) ModifyDate

func (e *Data) ModifyDate(tz *time.Location) (time.Time, error)

ModifyDate returns a time.Time that corresponds with when it was last modified. Since EXIF data does not contain any timezone information, you should select a timezone using tz. If tz is nil UTC is assumed.

func (*Data) Orientation

func (e *Data) Orientation() meta.Orientation

Orientation convenience func. If the tag is missing, OrientationHorizontal (normal) and ErrEmptyTag will be returned.

func (*Data) ParseASCIIValue

func (e *Data) ParseASCIIValue(t tag.Tag) (value string, err error)

ParseASCIIValue parses the ASCII value of the tag as a string and returns an error if it encounters one

func (*Data) ParseGPSCoord

func (e *Data) ParseGPSCoord(refTag tag.Tag, coordTag tag.Tag) (coord float64, err error)

ParseGPSCoord parses the GPS Coordinate (Lat or Lng) with the corresponding reference Tag.

func (*Data) ParseGPSTimeStamp

func (e *Data) ParseGPSTimeStamp(ds tag.Tag, ts tag.Tag, subSec tag.Tag, tz *time.Location) (t time.Time, err error)

ParseGPSTimeStamp parses the GPSDateStamp, GPSTimeStamp Tags in the given Timezone in UTC. Optionally add subSec tag from Exif.

func (*Data) ParseIfd

func (e *Data) ParseIfd(header meta.ExifHeader) error

func (*Data) ParseRationalValue

func (e *Data) ParseRationalValue(t tag.Tag) (n, d uint32, err error)

ParseRationalValue parses the Rational value and returns a numerator and denominator for a single Unsigned Rational

func (*Data) ParseRationalValues

func (e *Data) ParseRationalValues(t tag.Tag) (value []tag.Rational, err error)

ParseRationalValues returns a list of unsignedRationals

func (*Data) ParseSRationalValue

func (e *Data) ParseSRationalValue(t tag.Tag) (num, denom int32, err error)

ParseSRationalValue returns a numerator and denominator for a single Signed Rational

func (*Data) ParseSRationalValues

func (e *Data) ParseSRationalValues(t tag.Tag) (value []tag.SRational, err error)

ParseSRationalValues returns a list of unsignedRationals

func (*Data) ParseSubSec

func (e *Data) ParseSubSec(subSec tag.Tag) (int, error)

ParseSubSec parses a Subsecond Tag and returns an int in Nanoseconds. Returns ErrParseSubSecond if an err occurs

func (*Data) ParseTimeStamp

func (e *Data) ParseTimeStamp(date tag.Tag, subSec tag.Tag, tz *time.Location) (t time.Time, err error)

ParseTimeStamp parses a time.Time from 2 ASCII Tag's. ex: 1997:09:01 12:00:00 Based on: http://www.cipa.jp/std/documents/e/DC-008-2012_E.pdf (Last checked: 24/02/2021)

func (*Data) ParseUint16Value

func (e *Data) ParseUint16Value(t tag.Tag) (uint16, error)

ParseUint16Value returns the Short value of the tag as a uint16 and returns an error if it encounters one.

Warning: it returns only the first value if there are more values use Uint16Values function

func (*Data) ParseUint16Values

func (e *Data) ParseUint16Values(t tag.Tag) (value []uint16, err error)

ParseUint16Values parses the Short value of the tag as a uint16 array and returns an error if it encounters one.

func (*Data) ParseUint32Value

func (e *Data) ParseUint32Value(t tag.Tag) (value uint32, err error)

ParseUint32Value returns the Short or Long value of the tag as a uint32 and returns an error if it encounters one.

Warning: it returns only the first value if there are more values use Uint16Values (Short) or Unit32Values (Long) function

func (*Data) ParseUint32Values

func (e *Data) ParseUint32Values(t tag.Tag) (value []uint32, err error)

ParseUint32Values parses the Long value of the tag as a uint32 array and returns an error if it encounters one.

func (*Data) RangeTags

func (e *Data) RangeTags() chan tag.Tag

RangeTags returns a chan tag.Tag for the ranging over tags in exif.Data

func (*Data) ShutterSpeed

func (e *Data) ShutterSpeed() (meta.ShutterSpeed, error)

ShutterSpeed convenience func. "IFD/Exif" ExposureTime

type Exif

type Exif interface {
	// Aperture convenience func. "IFD/Exif" FNumber
	Aperture() (meta.Aperture, error)

	// Artist convenience func. "IFD" Artist
	Artist() (artist string, err error)

	// CameraSerial convenience func. "IFD/Exif" BodySerialNumber
	CameraSerial() (serial string, err error)

	// CameraMake convenience func. "IFD" Make
	CameraMake() (make string)

	// CameraModel convenience func. "IFD" Model
	CameraModel() (model string)

	// Copyright convenience func. "IFD" Copyright
	Copyright() (copyright string, err error)

	// Dimensions convenience func. "IFD" Dimensions
	Dimensions() (dimensions meta.Dimensions)

	// ExposureBias convenience func. "IFD/Exif" ExposureBiasValue
	ExposureBias() (meta.ExposureBias, error)

	// ExposureProgram convenience func. "IFD/Exif" ExposureProgram
	ExposureProgram() (meta.ExposureProgram, error)

	// ExposureMode convenience func. "IFD/Exif" ExposureMode
	ExposureMode() (meta.ExposureMode, error)

	// Flash convenience func. "IFD/Exif" Flash
	Flash() (meta.Flash, error)

	// FocalLength convenience func. "IFD/Exif" FocalLength
	// Lens Focal Length in mm
	FocalLength() (fl meta.FocalLength, err error)

	// FocalLengthIn35mmFilm convenience func. "IFD/Exif" FocalLengthIn35mmFilm
	// Lens Focal Length Equivalent for 35mm sensor in mm
	FocalLengthIn35mmFilm() (fl meta.FocalLength, err error)

	// ISOSpeed convenience func. "IFD/Exif" ISOSpeed
	ISOSpeed() (iso uint32, err error)

	// LensMake convenience func. "IFD/Exif" LensMake
	LensMake() (make string, err error)

	// LensModel convenience func. "IFD/Exif" LensModel
	LensModel() (model string, err error)

	// LensSerial convenience func. "IFD/Exif" LensSerialNumber
	LensSerial() (serial string, err error)

	// MeteringMode convenience func. "IFD/Exif" MeteringMode
	MeteringMode() (meta.MeteringMode, error)

	// Orientation convenience func. "IFD" Orientation
	Orientation() meta.Orientation

	// ShutterSpeed convenience func. "IFD/Exif" ExposureTime
	ShutterSpeed() (meta.ShutterSpeed, error)

	// GPSCoords convenience func. "IFD/GPS" Latitude and Longitude
	GPSCoords() (lat float64, lng float64, err error)

	// GPSCellID convenience func. "IFD/GPS" Latitude and Longitude converted to S2 cellID
	GPSCellID() (cellID s2.CellID, err error)

	// DateTime returns a time.Time that corresponds with when it was created.
	// Since EXIF data does not contain any timezone information, you should
	// select a timezone using tz. If tz is nil UTC is assumed.
	DateTime(tz *time.Location) (tm time.Time, err error)

	// ModifyDate returns a time.Time that corresponds with when it was last modified.
	// Since EXIF data does not contain any timezone information, you should
	// select a timezone using tz. If tz is nil UTC is assumed.
	ModifyDate(tz *time.Location) (time.Time, error)

	// GPSDate convenience func. for "IFD/GPS" GPSDateStamp and GPSTimeStamp.
	// Indicates the time as UTC (Coordinated Universal Time).
	// Optionally sets subsecond based on "IFD/Exif" SubSecTimeOriginal.
	// Sets time zone to time.UTC if non-provided.
	GPSDate(tz *time.Location) (t time.Time, err error)

	// GPSAltitude convenience func. for "IFD/GPS" GPSAltitude and GPSAltitudeRef.
	// Altitude is expressed as one RATIONAL value. The reference unit is meters.
	GPSAltitude() (alt float32, err error)

	// ExposureValue convenience func. "IFD/Exif" ShutterSpeedValue
	ExposureValue() (ev float32, err error)

	// CanonCameraSettings convenience func. "IFD/Exif/Makernotes.Canon" CanonCameraSettings
	// Canon Camera Settings from the Makernote
	CanonCameraSettings() (canon.CameraSettings, error)

	// CanonFileInfo convenience func. "IFD/Exif/Makernotes.Canon" CanonFileInfo
	// Canon Camera File Info from the Makernote
	CanonFileInfo() (canon.FileInfo, error)

	// CanonShotInfo convenience func. "IFD/Exif/Makernotes.Canon" CanonShotInfo
	// Canon Camera Shot Info from the Makernote
	CanonShotInfo() (canon.ShotInfo, error)

	// CanonAFInfo convenience func. "IFD/Exif/Makernotes.Canon" CanonAFInfo
	// Canon Camera AutoFocus Information from the Makernote
	CanonAFInfo() (afInfo canon.AFInfo, err error)
}

Exif is an interface representation of Exif Information

Directories

Path Synopsis
Package ifds provides types and functions for decoding tiff Ifds
Package ifds provides types and functions for decoding tiff Ifds
exififd
Package exififd provides types for "RootIfd/ExifIfd"
Package exififd provides types for "RootIfd/ExifIfd"
gpsifd
Package gpsifd provides types for "RootIfd/GPSIfd"
Package gpsifd provides types for "RootIfd/GPSIfd"
mknote
Package mknote provides functions and types for decoding Exif Makernote values
Package mknote provides functions and types for decoding Exif Makernote values
Package tag provides types and functions for decoding Exif Tags
Package tag provides types and functions for decoding Exif Tags

Jump to

Keyboard shortcuts

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