Documentation ¶
Index ¶
- Constants
- Variables
- type ExifHeader
- type ExifReader
- func (er *ExifReader) ByteOrder() binary.ByteOrder
- func (er *ExifReader) Read(p []byte) (n int, err error)
- func (er *ExifReader) ReadAt(p []byte, off int64) (n int, err error)
- func (er *ExifReader) SubReader(ifdOffset int64) *ExifReader
- func (er ExifReader) Visit(rootIfdName string, ifdMapping *IfdMapping, tagIndex TagIndex, ...) (err error)
- type ExifThumbnail
- type IfdEnumerate
- func (ie *IfdEnumerate) ParseIfd(fqIfdPath string, ifdIndex int, enumerator *IfdTagEnumerator, ...) (nextIfdOffset uint32, entries []*IfdTagEntry, thumbnailData []byte, err error)
- func (ie *IfdEnumerate) ParseIfd2(fqIfdPath string, ifdIndex int, enumerator *IfdTagEnumerator, ...) (nextIfdOffset uint32, entries []*IfdTagEntry, thumbnailData []byte, err error)
- func (ie *IfdEnumerate) Scan(rootIfdName string, ifdOffset uint32, visitor TagVisitorFn) (err error)
- type IfdMapping
- func (im *IfdMapping) GetChild(parentPathPhrase string, tagID exif.TagID) (mi *MappedIfd, err error)
- func (im *IfdMapping) GetParentPlacement(parentPlacement ifd.IfdPath) (childIfd *MappedIfd, err error)
- func (im *IfdMapping) GetWithPath(pathPhrase string) (mi *MappedIfd, err error)
- func (im *IfdMapping) LoadIfds(ifds ...ifd.IfdItem) (*IfdMapping, error)
- func (im *IfdMapping) PathPhraseFromLineage(lineage []IfdTagIdAndIndex) (pathPhrase string)
- func (im *IfdMapping) ResolvePath(pathPhrase string) (lineage []IfdTagIdAndIndex, err error)
- func (im *IfdMapping) StripPathPhraseIndices(pathPhrase string) (strippedPathPhrase string, err error)
- type IfdTagEntry
- func (ite *IfdTagEntry) ChildFqIfdPath() string
- func (ite *IfdTagEntry) ChildIfdName() string
- func (ite *IfdTagEntry) ChildIfdPath() string
- func (ite *IfdTagEntry) SetChildIfd(childFqIfdPath, childIfdPath, childIfdName string)
- func (ite *IfdTagEntry) SetTag(tag *exif.Tag)
- func (ite *IfdTagEntry) TagID() exif.TagID
- func (ite *IfdTagEntry) TagType() exif.TagType
- type IfdTagEnumerator
- type IfdTagIdAndIndex
- type MappedIfd
- type Reader
- type TagIndex
- type TagNameMap
- type TagVisitorFn
Constants ¶
const ( // ThumbnailOffsetTagID is IFD0/IFD1 Thumbnail Offset TagID ThumbnailOffsetTagID = 0x0201 // ThumbnailSizeTagID is IFD0/IFD1 Thumbnail Size TagID ThumbnailSizeTagID = 0x0202 )
const (
MaxExifSize int64 = 4 * 1024 * 1024
)
Options
Variables ¶
var ( ErrNoExif error = errors.New("Error no Exif") ErrExifNotValid = errors.New("Error Exif Not Valid") )
Errors
var ( ErrNoThumbnail = errors.New("No thumbnail") ErrNoGpsTags = errors.New("No GPS Tags") ErrTagTypeNotValid = errors.New("Tag Type invalid") )
Enumerator Errors
var ( ErrIfdNotFound = errors.New("Ifd Not Found") ErrTagNotFound = errors.New("Tag Not Found") )
Errors
var (
ErrChildIfdNotMapped = errors.New("no child-IFD for that tag-ID under parent")
)
Errors
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 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 ¶
type TagIndex ¶
TagIndex contains Tags by IFD
type TagNameMap ¶
type TagVisitorFn ¶
type TagVisitorFn func(fqIfdPath string, ifdIndex int, ite *IfdTagEntry) (err error)
TagVisitorFn is called for each tag when enumerating through the EXIF.