exiftool

package
v0.0.0-...-1f36970 Latest Latest
Warning

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

Go to latest
Published: May 13, 2020 License: BSD-2-Clause Imports: 8 Imported by: 2

README

// 2.CR2 with Makernote BenchmarkExifDecode200-8 6764 163791 ns/op 411423 B/op 465 allocs/op BenchmarkExifDecodeOld200-8 195 6485752 ns/op 51937961 B/op 16014 allocs/op BenchmarkExifDecodeOprea200-8 891 1380051 ns/op 278748 B/op 10461 allocs/op PASS

BenchmarkExifDecode200-8 7178 152143 ns/op 313108 B/op 463 allocs/op BenchmarkExifDecodeOld200-8 193 5928209 ns/op 51937915 B/op 16014 allocs/op BenchmarkExifDecodeOprea200-8 872 1340157 ns/op 278760 B/op 10461 allocs/op

BenchmarkExifDecode200-8 8109 149267 ns/op 313090 B/op 463 allocs/op BenchmarkExifDecodeOld200-8 160 6738374 ns/op 51937999 B/op 16015 allocs/op BenchmarkExifDecodeOprea200-8 903 1386518 ns/op 278741 B/op 10460 allocs/op

BenchmarkExif200-8 15232 79783 ns/op 35716 B/op 70 allocs/op BenchmarkExif200-8 14409 80618 ns/op 35717 B/op 70 allocs/op BenchmarkExif200-8 14349 81138 ns/op 35717 B/op 70 allocs/op

Documentation

Index

Constants

View Source
const (
	// ThumbnailOffsetTagID is IFD0/IFD1 Thumbnail Offset TagID
	ThumbnailOffsetTagID = 0x0201
	// ThumbnailSizeTagID is IFD0/IFD1 Thumbnail Size TagID
	ThumbnailSizeTagID = 0x0202
)
View Source
const (
	MaxExifSize int64 = 4 * 1024 * 1024
)

Options

Variables

View Source
var (
	ErrNoExif       error = errors.New("Error no Exif")
	ErrExifNotValid       = errors.New("Error Exif Not Valid")
)

Errors

View Source
var (
	ErrNoThumbnail     = errors.New("No thumbnail")
	ErrNoGpsTags       = errors.New("No GPS Tags")
	ErrTagTypeNotValid = errors.New("Tag Type invalid")
)

Enumerator Errors

View Source
var (
	ErrIfdNotFound = errors.New("Ifd Not Found")
	ErrTagNotFound = errors.New("Tag Not Found")
)

Errors

View Source
var (
	ErrChildIfdNotMapped = errors.New("no child-IFD for that tag-ID under parent")
)

Errors

View Source
var (
	ErrIfdNotValid = fmt.Errorf("Ifd not Valid")
)

Functions

This section is empty.

Types

type ExifHeader

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

ExifHeader is an Exif Header

func ParseExif

func ParseExif(r io.Reader) (eh *ExifHeader, err error)

ParseExif parses a an io.Reader and returns an ExifHeader. ErrNoExif is returned as an error if No Exif byte Header is found.

func (ExifHeader) NewExifReader

func (eh ExifHeader) NewExifReader(reader Reader) (*ExifReader, error)

NewExifReader creates a New ExifReader from an ExifHeader with the following reader

func (ExifHeader) Valid

func (eh ExifHeader) Valid() bool

Valid returns true for a valid ExifHeader

type ExifReader

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

ExifReader -

func NewExifReader

func NewExifReader(reader Reader, byteOrder binary.ByteOrder, firstIfdOffset uint32, exifOffset int64) *ExifReader

NewExifReader returns a new ExifReader. It reads from reader according to byteOrder from exifOffset

func ParseExif2

func ParseExif2(r Reader) (er *ExifReader, err error)

ParseExif2 parses a an io.Reader and returns an ExifReader. ErrNoExif is returned as an error if No Exif byte Header is found.

func (*ExifReader) ByteOrder

func (er *ExifReader) ByteOrder() binary.ByteOrder

func (*ExifReader) Read

func (er *ExifReader) Read(p []byte) (n int, err error)

Read reads from ExifReafer and moves the offset marker

func (*ExifReader) ReadAt

func (er *ExifReader) ReadAt(p []byte, off int64) (n int, err error)

ReadAt reads from ExifReader at the given offset

func (*ExifReader) SubReader

func (er *ExifReader) SubReader(ifdOffset int64) *ExifReader

SubReader returns an ExifReader with its offest set to IfdOffset and an empty index

func (ExifReader) Visit

func (er ExifReader) Visit(rootIfdName string, ifdMapping *IfdMapping, tagIndex TagIndex, visitor TagVisitorFn) (err error)

Visit recursively invokes a callback for every tag.

type ExifThumbnail

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

type IfdEnumerate

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

IfdEnumerate -

func (*IfdEnumerate) ParseIfd

func (ie *IfdEnumerate) ParseIfd(fqIfdPath string, ifdIndex int, enumerator *IfdTagEnumerator, visitor TagVisitorFn, doDescend bool) (nextIfdOffset uint32, entries []*IfdTagEntry, thumbnailData []byte, err error)

ParseIfd decodes the IFD block that we're currently sitting on the first byte of. WIP: Test & Benchmark

func (*IfdEnumerate) ParseIfd2

func (ie *IfdEnumerate) ParseIfd2(fqIfdPath string, ifdIndex int, enumerator *IfdTagEnumerator, visitor TagVisitorFn, doDescend bool) (nextIfdOffset uint32, entries []*IfdTagEntry, thumbnailData []byte, err error)

ParseIfd2 decodes the IFD block that we're currently sitting on the first byte of. WIP: Test & Benchmark

func (*IfdEnumerate) Scan

func (ie *IfdEnumerate) Scan(rootIfdName string, ifdOffset uint32, visitor TagVisitorFn) (err error)

Scan enumerates the different EXIF blocks (called IFDs). `rootIfdName` will be "IFD" in the TIFF standard.

type IfdMapping

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

IfdMapping describes all of the IFDs that we currently recognize.

func NewIfdMapping

func NewIfdMapping() (ifdMapping *IfdMapping)

NewIfdMapping creates an empty IfdMapping from the rootNode

func (*IfdMapping) GetChild

func (im *IfdMapping) GetChild(parentPathPhrase string, tagID exif.TagID) (mi *MappedIfd, err error)

GetChild is a convenience function to get the child path for a given parent placement and child tag-ID.

func (*IfdMapping) GetParentPlacement

func (im *IfdMapping) GetParentPlacement(parentPlacement ifd.IfdPath) (childIfd *MappedIfd, err error)

func (*IfdMapping) GetWithPath

func (im *IfdMapping) GetWithPath(pathPhrase string) (mi *MappedIfd, err error)

func (*IfdMapping) LoadIfds

func (im *IfdMapping) LoadIfds(ifds ...ifd.IfdItem) (*IfdMapping, error)

LoadIfds loads ifdItems in the IfdMapping

func (*IfdMapping) PathPhraseFromLineage

func (im *IfdMapping) PathPhraseFromLineage(lineage []IfdTagIdAndIndex) (pathPhrase string)

func (*IfdMapping) ResolvePath

func (im *IfdMapping) ResolvePath(pathPhrase string) (lineage []IfdTagIdAndIndex, err error)

ResolvePath takes a list of names, which can also be suffixed with indices (to identify the second, third, etc.. sibling IFD) and returns a list of tag-IDs and those indices.

Example:

- IFD/Exif/Iop - IFD0/Exif/Iop

This is the only call that supports adding the numeric indices.

func (*IfdMapping) StripPathPhraseIndices

func (im *IfdMapping) StripPathPhraseIndices(pathPhrase string) (strippedPathPhrase string, err error)

StripPathPhraseIndices returns a non-fully-qualified path-phrase (no indices).

type IfdTagEntry

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

IfdTagEntry refers to a tag in the loaded EXIF block.

func (*IfdTagEntry) ChildFqIfdPath

func (ite *IfdTagEntry) ChildFqIfdPath() string

ChildFqIfdPath returns the complete path of the child IFD along with the numeric suffixes differentiating sibling occurrences of the same type. "0" indices are omitted.

func (*IfdTagEntry) ChildIfdName

func (ite *IfdTagEntry) ChildIfdName() string

ChildIfdName returns the name of the child IFD

func (*IfdTagEntry) ChildIfdPath

func (ite *IfdTagEntry) ChildIfdPath() string

ChildIfdPath returns the path of the child IFD.

func (*IfdTagEntry) SetChildIfd

func (ite *IfdTagEntry) SetChildIfd(childFqIfdPath, childIfdPath, childIfdName string)

SetChildIfd sets child-IFD information (if we represent a child IFD).

func (*IfdTagEntry) SetTag

func (ite *IfdTagEntry) SetTag(tag *exif.Tag)
func (ite *IfdTagEntry) getValueContext() *exif.ValueContext {
	return exif.NewValueContext(
		ite.ifdPath,
		ite.tagID,
		ite.unitCount,
		ite.valueOffset,
		ite.rawValueOffset,
		ite.exifReader,
		ite.tagType,
		ite.byteOrder)
}

func (*IfdTagEntry) TagID

func (ite *IfdTagEntry) TagID() exif.TagID

TagID returns the ID of the tag that we represent. The combination of (IfdPath(), TagId()) is unique.

func (*IfdTagEntry) TagType

func (ite *IfdTagEntry) TagType() exif.TagType

TagType is the type of value for this tag.

type IfdTagEnumerator

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

IfdTagEnumerator knows how to decode an IFD and all of the tags it describes.

The IFDs and the actual values can float throughout the EXIF block, but the IFD itself is just a minor header followed by a set of repeating, statically-sized records. So, the tags (though notnecessarily their values) are fairly simple to enumerate.

type IfdTagIdAndIndex

type IfdTagIdAndIndex struct {
	Name  string
	TagID exif.TagID
	Index int
}

type MappedIfd

type MappedIfd struct {
	ParentTagID exif.TagID
	Placement   ifd.IfdPath
	Path        []string

	Name     string
	TagID    exif.TagID
	Children map[exif.TagID]*MappedIfd
}

MappedIfd -

func (*MappedIfd) PathPhrase

func (mi *MappedIfd) PathPhrase() string

type Reader

type Reader interface {
	io.ReaderAt
	io.Reader
}

Reader interface

type TagIndex

type TagIndex map[string]map[exif.TagID]exif.Tag

TagIndex contains Tags by IFD

func NewTagIndex

func NewTagIndex() TagIndex

NewTagIndex - creates a new empty TagIndex

func (TagIndex) Add

func (ti TagIndex) Add(fqIfdPath string, tagMap exif.TagMap)

Add adds a TagMap to a fdIfdPath

func (TagIndex) Get

func (ti TagIndex) Get(fqIfdPath string, tagID exif.TagID) (tag exif.Tag, err error)

Get returns information about the non-IFD tag.

type TagNameMap

type TagNameMap map[exif.TagID]string

func (TagNameMap) Name

func (tnm TagNameMap) Name(tagID exif.TagID) string

type TagVisitorFn

type TagVisitorFn func(fqIfdPath string, ifdIndex int, ite *IfdTagEntry) (err error)

TagVisitorFn is called for each tag when enumerating through the EXIF.

Directories

Path Synopsis
tags
ifd

Jump to

Keyboard shortcuts

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