summaryrefslogtreecommitdiff
path: root/vendor/github.com/dsoprea/go-exif/v2
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/github.com/dsoprea/go-exif/v2')
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/.MODULE_ROOT0
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/LICENSE9
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/ifd.go659
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/parser.go219
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/testing_common.go88
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/type.go452
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/utility.go79
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/value_context.go412
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/common/value_encoder.go229
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/error.go14
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/exif.go258
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/gps.go117
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/ifd.go34
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/ifd_builder.go1199
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/ifd_builder_encode.go532
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/ifd_enumerate.go1521
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/ifd_tag_entry.go297
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/package.go8
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/tags.go411
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/tags_data.go929
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/testing_common.go182
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/README.md4
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/accessor.go62
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_8828_oecf.go148
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9000_exif_version.go69
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9101_components_configuration.go124
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_927C_maker_note.go114
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9286_user_comment.go142
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A000_flashpix_version.go69
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A20C_spatial_frequency_response.go160
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A300_file_source.go79
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A301_scene_type.go76
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A302_cfa_pattern.go97
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/exif_iop_0002_interop_version.go69
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001B_gps_processing_method.go65
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001C_gps_area_information.go65
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/registration.go42
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/undefined/type.go44
-rw-r--r--vendor/github.com/dsoprea/go-exif/v2/utility.go233
39 files changed, 0 insertions, 9311 deletions
diff --git a/vendor/github.com/dsoprea/go-exif/v2/.MODULE_ROOT b/vendor/github.com/dsoprea/go-exif/v2/.MODULE_ROOT
deleted file mode 100644
index e69de29bb..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/.MODULE_ROOT
+++ /dev/null
diff --git a/vendor/github.com/dsoprea/go-exif/v2/LICENSE b/vendor/github.com/dsoprea/go-exif/v2/LICENSE
deleted file mode 100644
index 0b9358a3a..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/LICENSE
+++ /dev/null
@@ -1,9 +0,0 @@
-MIT LICENSE
-
-Copyright 2019 Dustin Oprea
-
-Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/ifd.go b/vendor/github.com/dsoprea/go-exif/v2/common/ifd.go
deleted file mode 100644
index 9b93f04d9..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/ifd.go
+++ /dev/null
@@ -1,659 +0,0 @@
-package exifcommon
-
-import (
- "errors"
- "fmt"
- "strings"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- ifdLogger = log.NewLogger("exifcommon.ifd")
-)
-
-var (
- ErrChildIfdNotMapped = errors.New("no child-IFD for that tag-ID under parent")
-)
-
-// MappedIfd is one node in the IFD-mapping.
-type MappedIfd struct {
- ParentTagId uint16
- Placement []uint16
- Path []string
-
- Name string
- TagId uint16
- Children map[uint16]*MappedIfd
-}
-
-// String returns a descriptive string.
-func (mi *MappedIfd) String() string {
- pathPhrase := mi.PathPhrase()
- return fmt.Sprintf("MappedIfd<(0x%04X) [%s] PATH=[%s]>", mi.TagId, mi.Name, pathPhrase)
-}
-
-// PathPhrase returns a non-fully-qualified IFD path.
-func (mi *MappedIfd) PathPhrase() string {
- return strings.Join(mi.Path, "/")
-}
-
-// TODO(dustin): Refactor this to use IfdIdentity structs.
-
-// IfdMapping describes all of the IFDs that we currently recognize.
-type IfdMapping struct {
- rootNode *MappedIfd
-}
-
-// NewIfdMapping returns a new IfdMapping struct.
-func NewIfdMapping() (ifdMapping *IfdMapping) {
- rootNode := &MappedIfd{
- Path: make([]string, 0),
- Children: make(map[uint16]*MappedIfd),
- }
-
- return &IfdMapping{
- rootNode: rootNode,
- }
-}
-
-// NewIfdMappingWithStandard retruns a new IfdMapping struct preloaded with the
-// standard IFDs.
-func NewIfdMappingWithStandard() (ifdMapping *IfdMapping) {
- defer func() {
- if state := recover(); state != nil {
- err := log.Wrap(state.(error))
- log.Panic(err)
- }
- }()
-
- im := NewIfdMapping()
-
- err := LoadStandardIfds(im)
- log.PanicIf(err)
-
- return im
-}
-
-// Get returns the node given the path slice.
-func (im *IfdMapping) Get(parentPlacement []uint16) (childIfd *MappedIfd, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ptr := im.rootNode
- for _, tagId := range parentPlacement {
- if descendantPtr, found := ptr.Children[tagId]; found == false {
- log.Panicf("ifd child with tag-ID (%04x) not registered: [%s]", tagId, ptr.PathPhrase())
- } else {
- ptr = descendantPtr
- }
- }
-
- return ptr, nil
-}
-
-// GetWithPath returns the node given the path string.
-func (im *IfdMapping) GetWithPath(pathPhrase string) (mi *MappedIfd, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if pathPhrase == "" {
- log.Panicf("path-phrase is empty")
- }
-
- path := strings.Split(pathPhrase, "/")
- ptr := im.rootNode
-
- for _, name := range path {
- var hit *MappedIfd
- for _, mi := range ptr.Children {
- if mi.Name == name {
- hit = mi
- break
- }
- }
-
- if hit == nil {
- log.Panicf("ifd child with name [%s] not registered: [%s]", name, ptr.PathPhrase())
- }
-
- ptr = hit
- }
-
- return ptr, nil
-}
-
-// GetChild is a convenience function to get the child path for a given parent
-// placement and child tag-ID.
-func (im *IfdMapping) GetChild(parentPathPhrase string, tagId uint16) (mi *MappedIfd, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- mi, err = im.GetWithPath(parentPathPhrase)
- log.PanicIf(err)
-
- for _, childMi := range mi.Children {
- if childMi.TagId == tagId {
- return childMi, nil
- }
- }
-
- // Whether or not an IFD is defined in data, such an IFD is not registered
- // and would be unknown.
- log.Panic(ErrChildIfdNotMapped)
- return nil, nil
-}
-
-// IfdTagIdAndIndex represents a specific part of the IFD path.
-//
-// This is a legacy type.
-type IfdTagIdAndIndex struct {
- Name string
- TagId uint16
- Index int
-}
-
-// String returns a descriptive string.
-func (itii IfdTagIdAndIndex) String() string {
- return fmt.Sprintf("IfdTagIdAndIndex<NAME=[%s] ID=(%04x) INDEX=(%d)>", itii.Name, itii.TagId, itii.Index)
-}
-
-// 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 (im *IfdMapping) ResolvePath(pathPhrase string) (lineage []IfdTagIdAndIndex, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- pathPhrase = strings.TrimSpace(pathPhrase)
-
- if pathPhrase == "" {
- log.Panicf("can not resolve empty path-phrase")
- }
-
- path := strings.Split(pathPhrase, "/")
- lineage = make([]IfdTagIdAndIndex, len(path))
-
- ptr := im.rootNode
- empty := IfdTagIdAndIndex{}
- for i, name := range path {
- indexByte := name[len(name)-1]
- index := 0
- if indexByte >= '0' && indexByte <= '9' {
- index = int(indexByte - '0')
- name = name[:len(name)-1]
- }
-
- itii := IfdTagIdAndIndex{}
- for _, mi := range ptr.Children {
- if mi.Name != name {
- continue
- }
-
- itii.Name = name
- itii.TagId = mi.TagId
- itii.Index = index
-
- ptr = mi
-
- break
- }
-
- if itii == empty {
- log.Panicf("ifd child with name [%s] not registered: [%s]", name, pathPhrase)
- }
-
- lineage[i] = itii
- }
-
- return lineage, nil
-}
-
-// FqPathPhraseFromLineage returns the fully-qualified IFD path from the slice.
-func (im *IfdMapping) FqPathPhraseFromLineage(lineage []IfdTagIdAndIndex) (fqPathPhrase string) {
- fqPathParts := make([]string, len(lineage))
- for i, itii := range lineage {
- if itii.Index > 0 {
- fqPathParts[i] = fmt.Sprintf("%s%d", itii.Name, itii.Index)
- } else {
- fqPathParts[i] = itii.Name
- }
- }
-
- return strings.Join(fqPathParts, "/")
-}
-
-// PathPhraseFromLineage returns the non-fully-qualified IFD path from the
-// slice.
-func (im *IfdMapping) PathPhraseFromLineage(lineage []IfdTagIdAndIndex) (pathPhrase string) {
- pathParts := make([]string, len(lineage))
- for i, itii := range lineage {
- pathParts[i] = itii.Name
- }
-
- return strings.Join(pathParts, "/")
-}
-
-// StripPathPhraseIndices returns a non-fully-qualified path-phrase (no
-// indices).
-func (im *IfdMapping) StripPathPhraseIndices(pathPhrase string) (strippedPathPhrase string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- lineage, err := im.ResolvePath(pathPhrase)
- log.PanicIf(err)
-
- strippedPathPhrase = im.PathPhraseFromLineage(lineage)
- return strippedPathPhrase, nil
-}
-
-// Add puts the given IFD at the given position of the tree. The position of the
-// tree is referred to as the placement and is represented by a set of tag-IDs,
-// where the leftmost is the root tag and the tags going to the right are
-// progressive descendants.
-func (im *IfdMapping) Add(parentPlacement []uint16, tagId uint16, name string) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! It would be nicer to provide a list of names in the placement rather than tag-IDs.
-
- ptr, err := im.Get(parentPlacement)
- log.PanicIf(err)
-
- path := make([]string, len(parentPlacement)+1)
- if len(parentPlacement) > 0 {
- copy(path, ptr.Path)
- }
-
- path[len(path)-1] = name
-
- placement := make([]uint16, len(parentPlacement)+1)
- if len(placement) > 0 {
- copy(placement, ptr.Placement)
- }
-
- placement[len(placement)-1] = tagId
-
- childIfd := &MappedIfd{
- ParentTagId: ptr.TagId,
- Path: path,
- Placement: placement,
- Name: name,
- TagId: tagId,
- Children: make(map[uint16]*MappedIfd),
- }
-
- if _, found := ptr.Children[tagId]; found == true {
- log.Panicf("child IFD with tag-ID (%04x) already registered under IFD [%s] with tag-ID (%04x)", tagId, ptr.Name, ptr.TagId)
- }
-
- ptr.Children[tagId] = childIfd
-
- return nil
-}
-
-func (im *IfdMapping) dumpLineages(stack []*MappedIfd, input []string) (output []string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- currentIfd := stack[len(stack)-1]
-
- output = input
- for _, childIfd := range currentIfd.Children {
- stackCopy := make([]*MappedIfd, len(stack)+1)
-
- copy(stackCopy, stack)
- stackCopy[len(stack)] = childIfd
-
- // Add to output, but don't include the obligatory root node.
- parts := make([]string, len(stackCopy)-1)
- for i, mi := range stackCopy[1:] {
- parts[i] = mi.Name
- }
-
- output = append(output, strings.Join(parts, "/"))
-
- output, err = im.dumpLineages(stackCopy, output)
- log.PanicIf(err)
- }
-
- return output, nil
-}
-
-// DumpLineages returns a slice of strings representing all mappings.
-func (im *IfdMapping) DumpLineages() (output []string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- stack := []*MappedIfd{im.rootNode}
- output = make([]string, 0)
-
- output, err = im.dumpLineages(stack, output)
- log.PanicIf(err)
-
- return output, nil
-}
-
-// LoadStandardIfds loads the standard IFDs into the mapping.
-func LoadStandardIfds(im *IfdMapping) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = im.Add(
- []uint16{},
- IfdStandardIfdIdentity.TagId(), IfdStandardIfdIdentity.Name())
-
- log.PanicIf(err)
-
- err = im.Add(
- []uint16{IfdStandardIfdIdentity.TagId()},
- IfdExifStandardIfdIdentity.TagId(), IfdExifStandardIfdIdentity.Name())
-
- log.PanicIf(err)
-
- err = im.Add(
- []uint16{IfdStandardIfdIdentity.TagId(), IfdExifStandardIfdIdentity.TagId()},
- IfdExifIopStandardIfdIdentity.TagId(), IfdExifIopStandardIfdIdentity.Name())
-
- log.PanicIf(err)
-
- err = im.Add(
- []uint16{IfdStandardIfdIdentity.TagId()},
- IfdGpsInfoStandardIfdIdentity.TagId(), IfdGpsInfoStandardIfdIdentity.Name())
-
- log.PanicIf(err)
-
- return nil
-}
-
-// IfdTag describes a single IFD tag and its parent (if any).
-type IfdTag struct {
- parentIfdTag *IfdTag
- tagId uint16
- name string
-}
-
-func NewIfdTag(parentIfdTag *IfdTag, tagId uint16, name string) IfdTag {
- return IfdTag{
- parentIfdTag: parentIfdTag,
- tagId: tagId,
- name: name,
- }
-}
-
-// ParentIfd returns the IfdTag of this IFD's parent.
-func (it IfdTag) ParentIfd() *IfdTag {
- return it.parentIfdTag
-}
-
-// TagId returns the tag-ID of this IFD.
-func (it IfdTag) TagId() uint16 {
- return it.tagId
-}
-
-// Name returns the simple name of this IFD.
-func (it IfdTag) Name() string {
- return it.name
-}
-
-// String returns a descriptive string.
-func (it IfdTag) String() string {
- parentIfdPhrase := ""
- if it.parentIfdTag != nil {
- parentIfdPhrase = fmt.Sprintf(" PARENT=(0x%04x)[%s]", it.parentIfdTag.tagId, it.parentIfdTag.name)
- }
-
- return fmt.Sprintf("IfdTag<TAG-ID=(0x%04x) NAME=[%s]%s>", it.tagId, it.name, parentIfdPhrase)
-}
-
-var (
- // rootStandardIfd is the standard root IFD.
- rootStandardIfd = NewIfdTag(nil, 0x0000, "IFD") // IFD
-
- // exifStandardIfd is the standard "Exif" IFD.
- exifStandardIfd = NewIfdTag(&rootStandardIfd, 0x8769, "Exif") // IFD/Exif
-
- // iopStandardIfd is the standard "Iop" IFD.
- iopStandardIfd = NewIfdTag(&exifStandardIfd, 0xA005, "Iop") // IFD/Exif/Iop
-
- // gpsInfoStandardIfd is the standard "GPS" IFD.
- gpsInfoStandardIfd = NewIfdTag(&rootStandardIfd, 0x8825, "GPSInfo") // IFD/GPSInfo
-)
-
-// IfdIdentityPart represents one component in an IFD path.
-type IfdIdentityPart struct {
- Name string
- Index int
-}
-
-// String returns a fully-qualified IFD path.
-func (iip IfdIdentityPart) String() string {
- if iip.Index > 0 {
- return fmt.Sprintf("%s%d", iip.Name, iip.Index)
- } else {
- return iip.Name
- }
-}
-
-// UnindexedString returned a non-fully-qualified IFD path.
-func (iip IfdIdentityPart) UnindexedString() string {
- return iip.Name
-}
-
-// IfdIdentity represents a single IFD path and provides access to various
-// information and representations.
-//
-// Only global instances can be used for equality checks.
-type IfdIdentity struct {
- ifdTag IfdTag
- parts []IfdIdentityPart
- ifdPath string
- fqIfdPath string
-}
-
-// NewIfdIdentity returns a new IfdIdentity struct.
-func NewIfdIdentity(ifdTag IfdTag, parts ...IfdIdentityPart) (ii *IfdIdentity) {
- ii = &IfdIdentity{
- ifdTag: ifdTag,
- parts: parts,
- }
-
- ii.ifdPath = ii.getIfdPath()
- ii.fqIfdPath = ii.getFqIfdPath()
-
- return ii
-}
-
-// NewIfdIdentityFromString parses a string like "IFD/Exif" or "IFD1" or
-// something more exotic with custom IFDs ("SomeIFD4/SomeChildIFD6"). Note that
-// this will valid the unindexed IFD structure (because the standard tags from
-// the specification are unindexed), but not, obviously, any indices (e.g.
-// the numbers in "IFD0", "IFD1", "SomeIFD4/SomeChildIFD6"). It is
-// required for the caller to check whether these specific instances
-// were actually parsed out of the stream.
-func NewIfdIdentityFromString(im *IfdMapping, fqIfdPath string) (ii *IfdIdentity, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- lineage, err := im.ResolvePath(fqIfdPath)
- log.PanicIf(err)
-
- var lastIt *IfdTag
- identityParts := make([]IfdIdentityPart, len(lineage))
- for i, itii := range lineage {
- // Build out the tag that will eventually point to the IFD represented
- // by the right-most part in the IFD path.
-
- it := &IfdTag{
- parentIfdTag: lastIt,
- tagId: itii.TagId,
- name: itii.Name,
- }
-
- lastIt = it
-
- // Create the next IfdIdentity part.
-
- iip := IfdIdentityPart{
- Name: itii.Name,
- Index: itii.Index,
- }
-
- identityParts[i] = iip
- }
-
- ii = NewIfdIdentity(*lastIt, identityParts...)
- return ii, nil
-}
-
-func (ii *IfdIdentity) getFqIfdPath() string {
- partPhrases := make([]string, len(ii.parts))
- for i, iip := range ii.parts {
- partPhrases[i] = iip.String()
- }
-
- return strings.Join(partPhrases, "/")
-}
-
-func (ii *IfdIdentity) getIfdPath() string {
- partPhrases := make([]string, len(ii.parts))
- for i, iip := range ii.parts {
- partPhrases[i] = iip.UnindexedString()
- }
-
- return strings.Join(partPhrases, "/")
-}
-
-// String returns a fully-qualified IFD path.
-func (ii *IfdIdentity) String() string {
- return ii.fqIfdPath
-}
-
-// UnindexedString returns a non-fully-qualified IFD path.
-func (ii *IfdIdentity) UnindexedString() string {
- return ii.ifdPath
-}
-
-// IfdTag returns the tag struct behind this IFD.
-func (ii *IfdIdentity) IfdTag() IfdTag {
- return ii.ifdTag
-}
-
-// TagId returns the tag-ID of the IFD.
-func (ii *IfdIdentity) TagId() uint16 {
- return ii.ifdTag.TagId()
-}
-
-// LeafPathPart returns the last right-most path-part, which represents the
-// current IFD.
-func (ii *IfdIdentity) LeafPathPart() IfdIdentityPart {
- return ii.parts[len(ii.parts)-1]
-}
-
-// Name returns the simple name of this IFD.
-func (ii *IfdIdentity) Name() string {
- return ii.LeafPathPart().Name
-}
-
-// Index returns the index of this IFD (more then one IFD under a parent IFD
-// will be numbered [0..n]).
-func (ii *IfdIdentity) Index() int {
- return ii.LeafPathPart().Index
-}
-
-// Equals returns true if the two IfdIdentity instances are effectively
-// identical.
-//
-// Since there's no way to get a specific fully-qualified IFD path without a
-// certain slice of parts and all other fields are also derived from this,
-// checking that the fully-qualified IFD path is equals is sufficient.
-func (ii *IfdIdentity) Equals(ii2 *IfdIdentity) bool {
- return ii.String() == ii2.String()
-}
-
-// NewChild creates an IfdIdentity for an IFD that is a child of the current
-// IFD.
-func (ii *IfdIdentity) NewChild(childIfdTag IfdTag, index int) (iiChild *IfdIdentity) {
- if *childIfdTag.parentIfdTag != ii.ifdTag {
- log.Panicf("can not add child; we are not the parent:\nUS=%v\nCHILD=%v", ii.ifdTag, childIfdTag)
- }
-
- childPart := IfdIdentityPart{childIfdTag.name, index}
- childParts := append(ii.parts, childPart)
-
- iiChild = NewIfdIdentity(childIfdTag, childParts...)
- return iiChild
-}
-
-// NewSibling creates an IfdIdentity for an IFD that is a sibling to the current
-// one.
-func (ii *IfdIdentity) NewSibling(index int) (iiSibling *IfdIdentity) {
- parts := make([]IfdIdentityPart, len(ii.parts))
-
- copy(parts, ii.parts)
- parts[len(parts)-1].Index = index
-
- iiSibling = NewIfdIdentity(ii.ifdTag, parts...)
- return iiSibling
-}
-
-var (
- // IfdStandardIfdIdentity represents the IFD path for IFD0.
- IfdStandardIfdIdentity = NewIfdIdentity(rootStandardIfd, IfdIdentityPart{"IFD", 0})
-
- // IfdExifStandardIfdIdentity represents the IFD path for IFD0/Exif0.
- IfdExifStandardIfdIdentity = IfdStandardIfdIdentity.NewChild(exifStandardIfd, 0)
-
- // IfdExifIopStandardIfdIdentity represents the IFD path for IFD0/Exif0/Iop0.
- IfdExifIopStandardIfdIdentity = IfdExifStandardIfdIdentity.NewChild(iopStandardIfd, 0)
-
- // IfdGPSInfoStandardIfdIdentity represents the IFD path for IFD0/GPSInfo0.
- IfdGpsInfoStandardIfdIdentity = IfdStandardIfdIdentity.NewChild(gpsInfoStandardIfd, 0)
-
- // Ifd1StandardIfdIdentity represents the IFD path for IFD1.
- Ifd1StandardIfdIdentity = NewIfdIdentity(rootStandardIfd, IfdIdentityPart{"IFD", 1})
-)
-
-var (
- IfdPathStandard = IfdStandardIfdIdentity
- IfdPathStandardExif = IfdExifStandardIfdIdentity
- IfdPathStandardExifIop = IfdExifIopStandardIfdIdentity
- IfdPathStandardGps = IfdGpsInfoStandardIfdIdentity
-)
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/parser.go b/vendor/github.com/dsoprea/go-exif/v2/common/parser.go
deleted file mode 100644
index bbdd8f53a..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/parser.go
+++ /dev/null
@@ -1,219 +0,0 @@
-package exifcommon
-
-import (
- "bytes"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- parserLogger = log.NewLogger("exifcommon.parser")
-)
-
-// Parser knows how to parse all well-defined, encoded EXIF types.
-type Parser struct {
-}
-
-// ParseBytesknows how to parse a byte-type value.
-func (p *Parser) ParseBytes(data []byte, unitCount uint32) (value []uint8, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeByte.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- value = []uint8(data[:count])
-
- return value, nil
-}
-
-// ParseAscii returns a string and auto-strips the trailing NUL character that
-// should be at the end of the encoding.
-func (p *Parser) ParseAscii(data []byte, unitCount uint32) (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeAscii.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- if len(data) == 0 || data[count-1] != 0 {
- s := string(data[:count])
- parserLogger.Warningf(nil, "ascii not terminated with nul as expected: [%v]", s)
-
- return s, nil
- }
-
- // Auto-strip the NUL from the end. It serves no purpose outside of
- // encoding semantics.
-
- return string(data[:count-1]), nil
-}
-
-// ParseAsciiNoNul returns a string without any consideration for a trailing NUL
-// character.
-func (p *Parser) ParseAsciiNoNul(data []byte, unitCount uint32) (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeAscii.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- return string(data[:count]), nil
-}
-
-// ParseShorts knows how to parse an encoded list of shorts.
-func (p *Parser) ParseShorts(data []byte, unitCount uint32, byteOrder binary.ByteOrder) (value []uint16, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeShort.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- value = make([]uint16, count)
- for i := 0; i < count; i++ {
- value[i] = byteOrder.Uint16(data[i*2:])
- }
-
- return value, nil
-}
-
-// ParseLongs knows how to encode an encoded list of unsigned longs.
-func (p *Parser) ParseLongs(data []byte, unitCount uint32, byteOrder binary.ByteOrder) (value []uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeLong.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- value = make([]uint32, count)
- for i := 0; i < count; i++ {
- value[i] = byteOrder.Uint32(data[i*4:])
- }
-
- return value, nil
-}
-
-// ParseRationals knows how to parse an encoded list of unsigned rationals.
-func (p *Parser) ParseRationals(data []byte, unitCount uint32, byteOrder binary.ByteOrder) (value []Rational, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeRational.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- value = make([]Rational, count)
- for i := 0; i < count; i++ {
- value[i].Numerator = byteOrder.Uint32(data[i*8:])
- value[i].Denominator = byteOrder.Uint32(data[i*8+4:])
- }
-
- return value, nil
-}
-
-// ParseSignedLongs knows how to parse an encoded list of signed longs.
-func (p *Parser) ParseSignedLongs(data []byte, unitCount uint32, byteOrder binary.ByteOrder) (value []int32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeSignedLong.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- b := bytes.NewBuffer(data)
-
- value = make([]int32, count)
- for i := 0; i < count; i++ {
- err := binary.Read(b, byteOrder, &value[i])
- log.PanicIf(err)
- }
-
- return value, nil
-}
-
-// ParseSignedRationals knows how to parse an encoded list of signed
-// rationals.
-func (p *Parser) ParseSignedRationals(data []byte, unitCount uint32, byteOrder binary.ByteOrder) (value []SignedRational, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- count := int(unitCount)
-
- if len(data) < (TypeSignedRational.Size() * count) {
- log.Panic(ErrNotEnoughData)
- }
-
- b := bytes.NewBuffer(data)
-
- value = make([]SignedRational, count)
- for i := 0; i < count; i++ {
- err = binary.Read(b, byteOrder, &value[i].Numerator)
- log.PanicIf(err)
-
- err = binary.Read(b, byteOrder, &value[i].Denominator)
- log.PanicIf(err)
- }
-
- return value, nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/testing_common.go b/vendor/github.com/dsoprea/go-exif/v2/common/testing_common.go
deleted file mode 100644
index f04fa22b6..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/testing_common.go
+++ /dev/null
@@ -1,88 +0,0 @@
-package exifcommon
-
-import (
- "os"
- "path"
-
- "encoding/binary"
- "io/ioutil"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- moduleRootPath = ""
-
- testExifData []byte = nil
-
- // EncodeDefaultByteOrder is the default byte-order for encoding operations.
- EncodeDefaultByteOrder = binary.BigEndian
-
- // Default byte order for tests.
- TestDefaultByteOrder = binary.BigEndian
-)
-
-func GetModuleRootPath() string {
- if moduleRootPath == "" {
- moduleRootPath = os.Getenv("EXIF_MODULE_ROOT_PATH")
- if moduleRootPath != "" {
- return moduleRootPath
- }
-
- currentWd, err := os.Getwd()
- log.PanicIf(err)
-
- currentPath := currentWd
-
- visited := make([]string, 0)
-
- for {
- tryStampFilepath := path.Join(currentPath, ".MODULE_ROOT")
-
- _, err := os.Stat(tryStampFilepath)
- if err != nil && os.IsNotExist(err) != true {
- log.Panic(err)
- } else if err == nil {
- break
- }
-
- visited = append(visited, tryStampFilepath)
-
- currentPath = path.Dir(currentPath)
- if currentPath == "/" {
- log.Panicf("could not find module-root: %v", visited)
- }
- }
-
- moduleRootPath = currentPath
- }
-
- return moduleRootPath
-}
-
-func GetTestAssetsPath() string {
- moduleRootPath := GetModuleRootPath()
- assetsPath := path.Join(moduleRootPath, "assets")
-
- return assetsPath
-}
-
-func getTestImageFilepath() string {
- assetsPath := GetTestAssetsPath()
- testImageFilepath := path.Join(assetsPath, "NDM_8901.jpg")
- return testImageFilepath
-}
-
-func getTestExifData() []byte {
- if testExifData == nil {
- assetsPath := GetTestAssetsPath()
- filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
-
- var err error
-
- testExifData, err = ioutil.ReadFile(filepath)
- log.PanicIf(err)
- }
-
- return testExifData
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/type.go b/vendor/github.com/dsoprea/go-exif/v2/common/type.go
deleted file mode 100644
index 86b38d044..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/type.go
+++ /dev/null
@@ -1,452 +0,0 @@
-package exifcommon
-
-import (
- "errors"
- "fmt"
- "reflect"
- "strconv"
- "strings"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- typeLogger = log.NewLogger("exif.type")
-)
-
-var (
- // ErrNotEnoughData is used when there isn't enough data to accommodate what
- // we're trying to parse (sizeof(type) * unit_count).
- ErrNotEnoughData = errors.New("not enough data for type")
-
- // ErrWrongType is used when we try to parse anything other than the
- // current type.
- ErrWrongType = errors.New("wrong type, can not parse")
-
- // ErrUnhandledUndefinedTypedTag is used when we try to parse a tag that's
- // recorded as an "unknown" type but not a documented tag (therefore
- // leaving us not knowning how to read it).
- ErrUnhandledUndefinedTypedTag = errors.New("not a standard unknown-typed tag")
-)
-
-// TagTypePrimitive is a type-alias that let's us easily lookup type properties.
-type TagTypePrimitive uint16
-
-const (
- // TypeByte describes an encoded list of bytes.
- TypeByte TagTypePrimitive = 1
-
- // TypeAscii describes an encoded list of characters that is terminated
- // with a NUL in its encoded form.
- TypeAscii TagTypePrimitive = 2
-
- // TypeShort describes an encoded list of shorts.
- TypeShort TagTypePrimitive = 3
-
- // TypeLong describes an encoded list of longs.
- TypeLong TagTypePrimitive = 4
-
- // TypeRational describes an encoded list of rationals.
- TypeRational TagTypePrimitive = 5
-
- // TypeUndefined describes an encoded value that has a complex/non-clearcut
- // interpretation.
- TypeUndefined TagTypePrimitive = 7
-
- // We've seen type-8, but have no documentation on it.
-
- // TypeSignedLong describes an encoded list of signed longs.
- TypeSignedLong TagTypePrimitive = 9
-
- // TypeSignedRational describes an encoded list of signed rationals.
- TypeSignedRational TagTypePrimitive = 10
-
- // TypeAsciiNoNul is just a pseudo-type, for our own purposes.
- TypeAsciiNoNul TagTypePrimitive = 0xf0
-)
-
-// String returns the name of the type
-func (typeType TagTypePrimitive) String() string {
- return TypeNames[typeType]
-}
-
-// Size returns the size of one atomic unit of the type.
-func (tagType TagTypePrimitive) Size() int {
- if tagType == TypeByte {
- return 1
- } else if tagType == TypeAscii || tagType == TypeAsciiNoNul {
- return 1
- } else if tagType == TypeShort {
- return 2
- } else if tagType == TypeLong {
- return 4
- } else if tagType == TypeRational {
- return 8
- } else if tagType == TypeSignedLong {
- return 4
- } else if tagType == TypeSignedRational {
- return 8
- } else {
- log.Panicf("can not determine tag-value size for type (%d): [%s]", tagType, TypeNames[tagType])
-
- // Never called.
- return 0
- }
-}
-
-// IsValid returns true if tagType is a valid type.
-func (tagType TagTypePrimitive) IsValid() bool {
-
- // TODO(dustin): Add test
-
- return tagType == TypeByte ||
- tagType == TypeAscii ||
- tagType == TypeAsciiNoNul ||
- tagType == TypeShort ||
- tagType == TypeLong ||
- tagType == TypeRational ||
- tagType == TypeSignedLong ||
- tagType == TypeSignedRational ||
- tagType == TypeUndefined
-}
-
-var (
- // TODO(dustin): Rename TypeNames() to typeNames() and add getter.
- TypeNames = map[TagTypePrimitive]string{
- TypeByte: "BYTE",
- TypeAscii: "ASCII",
- TypeShort: "SHORT",
- TypeLong: "LONG",
- TypeRational: "RATIONAL",
- TypeUndefined: "UNDEFINED",
- TypeSignedLong: "SLONG",
- TypeSignedRational: "SRATIONAL",
-
- TypeAsciiNoNul: "_ASCII_NO_NUL",
- }
-
- typeNamesR = map[string]TagTypePrimitive{}
-)
-
-// Rational describes an unsigned rational value.
-type Rational struct {
- // Numerator is the numerator of the rational value.
- Numerator uint32
-
- // Denominator is the numerator of the rational value.
- Denominator uint32
-}
-
-// SignedRational describes a signed rational value.
-type SignedRational struct {
- // Numerator is the numerator of the rational value.
- Numerator int32
-
- // Denominator is the numerator of the rational value.
- Denominator int32
-}
-
-// Format returns a stringified value for the given encoding. Automatically
-// parses. Automatically calculates count based on type size. This function
-// also supports undefined-type values (the ones that we support, anyway) by
-// way of the String() method that they all require. We can't be more specific
-// because we're a base package and we can't refer to it.
-func FormatFromType(value interface{}, justFirst bool) (phrase string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test
-
- switch t := value.(type) {
- case []byte:
- return DumpBytesToString(t), nil
- case string:
- return t, nil
- case []uint16:
- if len(t) == 0 {
- return "", nil
- }
-
- if justFirst == true {
- var valueSuffix string
- if len(t) > 1 {
- valueSuffix = "..."
- }
-
- return fmt.Sprintf("%v%s", t[0], valueSuffix), nil
- }
-
- return fmt.Sprintf("%v", t), nil
- case []uint32:
- if len(t) == 0 {
- return "", nil
- }
-
- if justFirst == true {
- var valueSuffix string
- if len(t) > 1 {
- valueSuffix = "..."
- }
-
- return fmt.Sprintf("%v%s", t[0], valueSuffix), nil
- }
-
- return fmt.Sprintf("%v", t), nil
- case []Rational:
- if len(t) == 0 {
- return "", nil
- }
-
- parts := make([]string, len(t))
- for i, r := range t {
- parts[i] = fmt.Sprintf("%d/%d", r.Numerator, r.Denominator)
-
- if justFirst == true {
- break
- }
- }
-
- if justFirst == true {
- var valueSuffix string
- if len(t) > 1 {
- valueSuffix = "..."
- }
-
- return fmt.Sprintf("%v%s", parts[0], valueSuffix), nil
- }
-
- return fmt.Sprintf("%v", parts), nil
- case []int32:
- if len(t) == 0 {
- return "", nil
- }
-
- if justFirst == true {
- var valueSuffix string
- if len(t) > 1 {
- valueSuffix = "..."
- }
-
- return fmt.Sprintf("%v%s", t[0], valueSuffix), nil
- }
-
- return fmt.Sprintf("%v", t), nil
- case []SignedRational:
- if len(t) == 0 {
- return "", nil
- }
-
- parts := make([]string, len(t))
- for i, r := range t {
- parts[i] = fmt.Sprintf("%d/%d", r.Numerator, r.Denominator)
-
- if justFirst == true {
- break
- }
- }
-
- if justFirst == true {
- var valueSuffix string
- if len(t) > 1 {
- valueSuffix = "..."
- }
-
- return fmt.Sprintf("%v%s", parts[0], valueSuffix), nil
- }
-
- return fmt.Sprintf("%v", parts), nil
- case fmt.Stringer:
- // An undefined value that is documented (or that we otherwise support).
- return t.String(), nil
- default:
- // Affects only "unknown" values, in general.
- log.Panicf("type can not be formatted into string: %v", reflect.TypeOf(value).Name())
-
- // Never called.
- return "", nil
- }
-}
-
-// Format returns a stringified value for the given encoding. Automatically
-// parses. Automatically calculates count based on type size.
-func FormatFromBytes(rawBytes []byte, tagType TagTypePrimitive, justFirst bool, byteOrder binary.ByteOrder) (phrase string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test
-
- typeSize := tagType.Size()
-
- if len(rawBytes)%typeSize != 0 {
- log.Panicf("byte-count (%d) does not align for [%s] type with a size of (%d) bytes", len(rawBytes), TypeNames[tagType], typeSize)
- }
-
- // unitCount is the calculated unit-count. This should equal the original
- // value from the tag (pre-resolution).
- unitCount := uint32(len(rawBytes) / typeSize)
-
- // Truncate the items if it's not bytes or a string and we just want the first.
-
- var value interface{}
-
- switch tagType {
- case TypeByte:
- var err error
-
- value, err = parser.ParseBytes(rawBytes, unitCount)
- log.PanicIf(err)
- case TypeAscii:
- var err error
-
- value, err = parser.ParseAscii(rawBytes, unitCount)
- log.PanicIf(err)
- case TypeAsciiNoNul:
- var err error
-
- value, err = parser.ParseAsciiNoNul(rawBytes, unitCount)
- log.PanicIf(err)
- case TypeShort:
- var err error
-
- value, err = parser.ParseShorts(rawBytes, unitCount, byteOrder)
- log.PanicIf(err)
- case TypeLong:
- var err error
-
- value, err = parser.ParseLongs(rawBytes, unitCount, byteOrder)
- log.PanicIf(err)
- case TypeRational:
- var err error
-
- value, err = parser.ParseRationals(rawBytes, unitCount, byteOrder)
- log.PanicIf(err)
- case TypeSignedLong:
- var err error
-
- value, err = parser.ParseSignedLongs(rawBytes, unitCount, byteOrder)
- log.PanicIf(err)
- case TypeSignedRational:
- var err error
-
- value, err = parser.ParseSignedRationals(rawBytes, unitCount, byteOrder)
- log.PanicIf(err)
- default:
- // Affects only "unknown" values, in general.
- log.Panicf("value of type [%s] can not be formatted into string", tagType.String())
-
- // Never called.
- return "", nil
- }
-
- phrase, err = FormatFromType(value, justFirst)
- log.PanicIf(err)
-
- return phrase, nil
-}
-
-// TranslateStringToType converts user-provided strings to properly-typed
-// values. If a string, returns a string. Else, assumes that it's a single
-// number. If a list needs to be processed, it is the caller's responsibility to
-// split it (according to whichever convention has been established).
-func TranslateStringToType(tagType TagTypePrimitive, valueString string) (value interface{}, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if tagType == TypeUndefined {
- // The caller should just call String() on the decoded type.
- log.Panicf("undefined-type values are not supported")
- }
-
- if tagType == TypeByte {
- wide, err := strconv.ParseInt(valueString, 16, 8)
- log.PanicIf(err)
-
- return byte(wide), nil
- } else if tagType == TypeAscii || tagType == TypeAsciiNoNul {
- // Whether or not we're putting an NUL on the end is only relevant for
- // byte-level encoding. This function really just supports a user
- // interface.
-
- return valueString, nil
- } else if tagType == TypeShort {
- n, err := strconv.ParseUint(valueString, 10, 16)
- log.PanicIf(err)
-
- return uint16(n), nil
- } else if tagType == TypeLong {
- n, err := strconv.ParseUint(valueString, 10, 32)
- log.PanicIf(err)
-
- return uint32(n), nil
- } else if tagType == TypeRational {
- parts := strings.SplitN(valueString, "/", 2)
-
- numerator, err := strconv.ParseUint(parts[0], 10, 32)
- log.PanicIf(err)
-
- denominator, err := strconv.ParseUint(parts[1], 10, 32)
- log.PanicIf(err)
-
- return Rational{
- Numerator: uint32(numerator),
- Denominator: uint32(denominator),
- }, nil
- } else if tagType == TypeSignedLong {
- n, err := strconv.ParseInt(valueString, 10, 32)
- log.PanicIf(err)
-
- return int32(n), nil
- } else if tagType == TypeSignedRational {
- parts := strings.SplitN(valueString, "/", 2)
-
- numerator, err := strconv.ParseInt(parts[0], 10, 32)
- log.PanicIf(err)
-
- denominator, err := strconv.ParseInt(parts[1], 10, 32)
- log.PanicIf(err)
-
- return SignedRational{
- Numerator: int32(numerator),
- Denominator: int32(denominator),
- }, nil
- }
-
- log.Panicf("from-string encoding for type not supported; this shouldn't happen: [%s]", tagType.String())
- return nil, nil
-}
-
-// GetTypeByName returns the `TagTypePrimitive` for the given type name.
-// Returns (0) if not valid.
-func GetTypeByName(typeName string) (tagType TagTypePrimitive, found bool) {
- tagType, found = typeNamesR[typeName]
- return tagType, found
-}
-
-// BasicTag describes a single tag for any purpose.
-type BasicTag struct {
- // FqIfdPath is the fully-qualified IFD-path.
- FqIfdPath string
-
- // IfdPath is the unindexed IFD-path.
- IfdPath string
-
- // TagId is the tag-ID.
- TagId uint16
-}
-
-func init() {
- for typeId, typeName := range TypeNames {
- typeNamesR[typeName] = typeId
- }
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/utility.go b/vendor/github.com/dsoprea/go-exif/v2/common/utility.go
deleted file mode 100644
index 65165bf02..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/utility.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package exifcommon
-
-import (
- "bytes"
- "fmt"
- "time"
-
- "github.com/dsoprea/go-logging"
-)
-
-// DumpBytes prints a list of hex-encoded bytes.
-func DumpBytes(data []byte) {
- fmt.Printf("DUMP: ")
- for _, x := range data {
- fmt.Printf("%02x ", x)
- }
-
- fmt.Printf("\n")
-}
-
-// DumpBytesClause prints a list like DumpBytes(), but encapsulated in
-// "[]byte { ... }".
-func DumpBytesClause(data []byte) {
- fmt.Printf("DUMP: ")
-
- fmt.Printf("[]byte { ")
-
- for i, x := range data {
- fmt.Printf("0x%02x", x)
-
- if i < len(data)-1 {
- fmt.Printf(", ")
- }
- }
-
- fmt.Printf(" }\n")
-}
-
-// DumpBytesToString returns a stringified list of hex-encoded bytes.
-func DumpBytesToString(data []byte) string {
- b := new(bytes.Buffer)
-
- for i, x := range data {
- _, err := b.WriteString(fmt.Sprintf("%02x", x))
- log.PanicIf(err)
-
- if i < len(data)-1 {
- _, err := b.WriteRune(' ')
- log.PanicIf(err)
- }
- }
-
- return b.String()
-}
-
-// DumpBytesClauseToString returns a comma-separated list of hex-encoded bytes.
-func DumpBytesClauseToString(data []byte) string {
- b := new(bytes.Buffer)
-
- for i, x := range data {
- _, err := b.WriteString(fmt.Sprintf("0x%02x", x))
- log.PanicIf(err)
-
- if i < len(data)-1 {
- _, err := b.WriteString(", ")
- log.PanicIf(err)
- }
- }
-
- return b.String()
-}
-
-// ExifFullTimestampString produces a string like "2018:11:30 13:01:49" from a
-// `time.Time` struct. It will attempt to convert to UTC first.
-func ExifFullTimestampString(t time.Time) (fullTimestampPhrase string) {
- t = t.UTC()
-
- return fmt.Sprintf("%04d:%02d:%02d %02d:%02d:%02d", t.Year(), t.Month(), t.Day(), t.Hour(), t.Minute(), t.Second())
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/value_context.go b/vendor/github.com/dsoprea/go-exif/v2/common/value_context.go
deleted file mode 100644
index feb078ccf..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/value_context.go
+++ /dev/null
@@ -1,412 +0,0 @@
-package exifcommon
-
-import (
- "errors"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- parser *Parser
-)
-
-var (
- // ErrNotFarValue indicates that an offset-based lookup was attempted for a
- // non-offset-based (embedded) value.
- ErrNotFarValue = errors.New("not a far value")
-)
-
-// ValueContext embeds all of the parameters required to find and extract the
-// actual tag value.
-type ValueContext struct {
- unitCount uint32
- valueOffset uint32
- rawValueOffset []byte
- addressableData []byte
-
- tagType TagTypePrimitive
- byteOrder binary.ByteOrder
-
- // undefinedValueTagType is the effective type to use if this is an
- // "undefined" value.
- undefinedValueTagType TagTypePrimitive
-
- ifdPath string
- tagId uint16
-}
-
-// TODO(dustin): We can update newValueContext() to derive `valueOffset` itself (from `rawValueOffset`).
-
-// NewValueContext returns a new ValueContext struct.
-func NewValueContext(ifdPath string, tagId uint16, unitCount, valueOffset uint32, rawValueOffset, addressableData []byte, tagType TagTypePrimitive, byteOrder binary.ByteOrder) *ValueContext {
- return &ValueContext{
- unitCount: unitCount,
- valueOffset: valueOffset,
- rawValueOffset: rawValueOffset,
- addressableData: addressableData,
-
- tagType: tagType,
- byteOrder: byteOrder,
-
- ifdPath: ifdPath,
- tagId: tagId,
- }
-}
-
-// SetUndefinedValueType sets the effective type if this is an unknown-type tag.
-func (vc *ValueContext) SetUndefinedValueType(tagType TagTypePrimitive) {
- if vc.tagType != TypeUndefined {
- log.Panicf("can not set effective type for unknown-type tag because this is *not* an unknown-type tag")
- }
-
- vc.undefinedValueTagType = tagType
-}
-
-// UnitCount returns the embedded unit-count.
-func (vc *ValueContext) UnitCount() uint32 {
- return vc.unitCount
-}
-
-// ValueOffset returns the value-offset decoded as a `uint32`.
-func (vc *ValueContext) ValueOffset() uint32 {
- return vc.valueOffset
-}
-
-// RawValueOffset returns the uninterpreted value-offset. This is used for
-// embedded values (values small enough to fit within the offset bytes rather
-// than needing to be stored elsewhere and referred to by an actual offset).
-func (vc *ValueContext) RawValueOffset() []byte {
- return vc.rawValueOffset
-}
-
-// AddressableData returns the block of data that we can dereference into.
-func (vc *ValueContext) AddressableData() []byte {
- return vc.addressableData
-}
-
-// ByteOrder returns the byte-order of numbers.
-func (vc *ValueContext) ByteOrder() binary.ByteOrder {
- return vc.byteOrder
-}
-
-// IfdPath returns the path of the IFD containing this tag.
-func (vc *ValueContext) IfdPath() string {
- return vc.ifdPath
-}
-
-// TagId returns the ID of the tag that we represent.
-func (vc *ValueContext) TagId() uint16 {
- return vc.tagId
-}
-
-// isEmbedded returns whether the value is embedded or a reference. This can't
-// be precalculated since the size is not defined for all types (namely the
-// "undefined" types).
-func (vc *ValueContext) isEmbedded() bool {
- tagType := vc.effectiveValueType()
-
- return (tagType.Size() * int(vc.unitCount)) <= 4
-}
-
-// SizeInBytes returns the number of bytes that this value requires. The
-// underlying call will panic if the type is UNDEFINED. It is the
-// responsibility of the caller to preemptively check that.
-func (vc *ValueContext) SizeInBytes() int {
- tagType := vc.effectiveValueType()
-
- return tagType.Size() * int(vc.unitCount)
-}
-
-// effectiveValueType returns the effective type of the unknown-type tag or, if
-// not unknown, the actual type.
-func (vc *ValueContext) effectiveValueType() (tagType TagTypePrimitive) {
- if vc.tagType == TypeUndefined {
- tagType = vc.undefinedValueTagType
-
- if tagType == 0 {
- log.Panicf("undefined-value type not set")
- }
- } else {
- tagType = vc.tagType
- }
-
- return tagType
-}
-
-// readRawEncoded returns the encoded bytes for the value that we represent.
-func (vc *ValueContext) readRawEncoded() (rawBytes []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- tagType := vc.effectiveValueType()
-
- unitSizeRaw := uint32(tagType.Size())
-
- if vc.isEmbedded() == true {
- byteLength := unitSizeRaw * vc.unitCount
- return vc.rawValueOffset[:byteLength], nil
- }
-
- return vc.addressableData[vc.valueOffset : vc.valueOffset+vc.unitCount*unitSizeRaw], nil
-}
-
-// GetFarOffset returns the offset if the value is not embedded [within the
-// pointer itself] or an error if an embedded value.
-func (vc *ValueContext) GetFarOffset() (offset uint32, err error) {
- if vc.isEmbedded() == true {
- return 0, ErrNotFarValue
- }
-
- return vc.valueOffset, nil
-}
-
-// ReadRawEncoded returns the encoded bytes for the value that we represent.
-func (vc *ValueContext) ReadRawEncoded() (rawBytes []byte, err error) {
-
- // TODO(dustin): Remove this method and rename readRawEncoded in its place.
-
- return vc.readRawEncoded()
-}
-
-// Format returns a string representation for the value.
-//
-// Where the type is not ASCII, `justFirst` indicates whether to just stringify
-// the first item in the slice (or return an empty string if the slice is
-// empty).
-//
-// Since this method lacks the information to process undefined-type tags (e.g.
-// byte-order, tag-ID, IFD type), it will return an error if attempted. See
-// `Undefined()`.
-func (vc *ValueContext) Format() (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawBytes, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- phrase, err := FormatFromBytes(rawBytes, vc.effectiveValueType(), false, vc.byteOrder)
- log.PanicIf(err)
-
- return phrase, nil
-}
-
-// FormatFirst is similar to `Format` but only gets and stringifies the first
-// item.
-func (vc *ValueContext) FormatFirst() (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawBytes, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- phrase, err := FormatFromBytes(rawBytes, vc.tagType, true, vc.byteOrder)
- log.PanicIf(err)
-
- return phrase, nil
-}
-
-// ReadBytes parses the encoded byte-array from the value-context.
-func (vc *ValueContext) ReadBytes() (value []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseBytes(rawValue, vc.unitCount)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadAscii parses the encoded NUL-terminated ASCII string from the value-
-// context.
-func (vc *ValueContext) ReadAscii() (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseAscii(rawValue, vc.unitCount)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadAsciiNoNul parses the non-NUL-terminated encoded ASCII string from the
-// value-context.
-func (vc *ValueContext) ReadAsciiNoNul() (value string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseAsciiNoNul(rawValue, vc.unitCount)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadShorts parses the list of encoded shorts from the value-context.
-func (vc *ValueContext) ReadShorts() (value []uint16, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseShorts(rawValue, vc.unitCount, vc.byteOrder)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadLongs parses the list of encoded, unsigned longs from the value-context.
-func (vc *ValueContext) ReadLongs() (value []uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseLongs(rawValue, vc.unitCount, vc.byteOrder)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadRationals parses the list of encoded, unsigned rationals from the value-
-// context.
-func (vc *ValueContext) ReadRationals() (value []Rational, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseRationals(rawValue, vc.unitCount, vc.byteOrder)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadSignedLongs parses the list of encoded, signed longs from the value-context.
-func (vc *ValueContext) ReadSignedLongs() (value []int32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseSignedLongs(rawValue, vc.unitCount, vc.byteOrder)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// ReadSignedRationals parses the list of encoded, signed rationals from the
-// value-context.
-func (vc *ValueContext) ReadSignedRationals() (value []SignedRational, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- rawValue, err := vc.readRawEncoded()
- log.PanicIf(err)
-
- value, err = parser.ParseSignedRationals(rawValue, vc.unitCount, vc.byteOrder)
- log.PanicIf(err)
-
- return value, nil
-}
-
-// Values knows how to resolve the given value. This value is always a list
-// (undefined-values aside), so we're named accordingly.
-//
-// Since this method lacks the information to process unknown-type tags (e.g.
-// byte-order, tag-ID, IFD type), it will return an error if attempted. See
-// `Undefined()`.
-func (vc *ValueContext) Values() (values interface{}, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if vc.tagType == TypeByte {
- values, err = vc.ReadBytes()
- log.PanicIf(err)
- } else if vc.tagType == TypeAscii {
- values, err = vc.ReadAscii()
- log.PanicIf(err)
- } else if vc.tagType == TypeAsciiNoNul {
- values, err = vc.ReadAsciiNoNul()
- log.PanicIf(err)
- } else if vc.tagType == TypeShort {
- values, err = vc.ReadShorts()
- log.PanicIf(err)
- } else if vc.tagType == TypeLong {
- values, err = vc.ReadLongs()
- log.PanicIf(err)
- } else if vc.tagType == TypeRational {
- values, err = vc.ReadRationals()
- log.PanicIf(err)
- } else if vc.tagType == TypeSignedLong {
- values, err = vc.ReadSignedLongs()
- log.PanicIf(err)
- } else if vc.tagType == TypeSignedRational {
- values, err = vc.ReadSignedRationals()
- log.PanicIf(err)
- } else if vc.tagType == TypeUndefined {
- log.Panicf("will not parse undefined-type value")
-
- // Never called.
- return nil, nil
- } else {
- log.Panicf("value of type [%s] is unparseable", vc.tagType)
- // Never called.
- return nil, nil
- }
-
- return values, nil
-}
-
-func init() {
- parser = new(Parser)
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/common/value_encoder.go b/vendor/github.com/dsoprea/go-exif/v2/common/value_encoder.go
deleted file mode 100644
index 52e0eacfd..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/common/value_encoder.go
+++ /dev/null
@@ -1,229 +0,0 @@
-package exifcommon
-
-import (
- "bytes"
- "reflect"
- "time"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-)
-
-var (
- typeEncodeLogger = log.NewLogger("exif.type_encode")
-)
-
-// EncodedData encapsulates the compound output of an encoding operation.
-type EncodedData struct {
- Type TagTypePrimitive
- Encoded []byte
-
- // TODO(dustin): Is this really necessary? We might have this just to correlate to the incoming stream format (raw bytes and a unit-count both for incoming and outgoing).
- UnitCount uint32
-}
-
-// ValueEncoder knows how to encode values of every type to bytes.
-type ValueEncoder struct {
- byteOrder binary.ByteOrder
-}
-
-// NewValueEncoder returns a new ValueEncoder.
-func NewValueEncoder(byteOrder binary.ByteOrder) *ValueEncoder {
- return &ValueEncoder{
- byteOrder: byteOrder,
- }
-}
-
-func (ve *ValueEncoder) encodeBytes(value []uint8) (ed EncodedData, err error) {
- ed.Type = TypeByte
- ed.Encoded = []byte(value)
- ed.UnitCount = uint32(len(value))
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeAscii(value string) (ed EncodedData, err error) {
- ed.Type = TypeAscii
-
- ed.Encoded = []byte(value)
- ed.Encoded = append(ed.Encoded, 0)
-
- ed.UnitCount = uint32(len(ed.Encoded))
-
- return ed, nil
-}
-
-// encodeAsciiNoNul returns a string encoded as a byte-string without a trailing
-// NUL byte.
-//
-// Note that:
-//
-// 1. This type can not be automatically encoded using `Encode()`. The default
-// mode is to encode *with* a trailing NUL byte using `encodeAscii`. Only
-// certain undefined-type tags using an unterminated ASCII string and these
-// are exceptional in nature.
-//
-// 2. The presence of this method allows us to completely test the complimentary
-// no-nul parser.
-//
-func (ve *ValueEncoder) encodeAsciiNoNul(value string) (ed EncodedData, err error) {
- ed.Type = TypeAsciiNoNul
- ed.Encoded = []byte(value)
- ed.UnitCount = uint32(len(ed.Encoded))
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeShorts(value []uint16) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ed.UnitCount = uint32(len(value))
- ed.Encoded = make([]byte, ed.UnitCount*2)
-
- for i := uint32(0); i < ed.UnitCount; i++ {
- ve.byteOrder.PutUint16(ed.Encoded[i*2:(i+1)*2], value[i])
- }
-
- ed.Type = TypeShort
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeLongs(value []uint32) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ed.UnitCount = uint32(len(value))
- ed.Encoded = make([]byte, ed.UnitCount*4)
-
- for i := uint32(0); i < ed.UnitCount; i++ {
- ve.byteOrder.PutUint32(ed.Encoded[i*4:(i+1)*4], value[i])
- }
-
- ed.Type = TypeLong
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeRationals(value []Rational) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ed.UnitCount = uint32(len(value))
- ed.Encoded = make([]byte, ed.UnitCount*8)
-
- for i := uint32(0); i < ed.UnitCount; i++ {
- ve.byteOrder.PutUint32(ed.Encoded[i*8+0:i*8+4], value[i].Numerator)
- ve.byteOrder.PutUint32(ed.Encoded[i*8+4:i*8+8], value[i].Denominator)
- }
-
- ed.Type = TypeRational
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeSignedLongs(value []int32) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ed.UnitCount = uint32(len(value))
-
- b := bytes.NewBuffer(make([]byte, 0, 8*ed.UnitCount))
-
- for i := uint32(0); i < ed.UnitCount; i++ {
- err := binary.Write(b, ve.byteOrder, value[i])
- log.PanicIf(err)
- }
-
- ed.Type = TypeSignedLong
- ed.Encoded = b.Bytes()
-
- return ed, nil
-}
-
-func (ve *ValueEncoder) encodeSignedRationals(value []SignedRational) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ed.UnitCount = uint32(len(value))
-
- b := bytes.NewBuffer(make([]byte, 0, 8*ed.UnitCount))
-
- for i := uint32(0); i < ed.UnitCount; i++ {
- err := binary.Write(b, ve.byteOrder, value[i].Numerator)
- log.PanicIf(err)
-
- err = binary.Write(b, ve.byteOrder, value[i].Denominator)
- log.PanicIf(err)
- }
-
- ed.Type = TypeSignedRational
- ed.Encoded = b.Bytes()
-
- return ed, nil
-}
-
-// Encode returns bytes for the given value, infering type from the actual
-// value. This does not support `TypeAsciiNoNull` (all strings are encoded as
-// `TypeAscii`).
-func (ve *ValueEncoder) Encode(value interface{}) (ed EncodedData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- switch value.(type) {
- case []byte:
- ed, err = ve.encodeBytes(value.([]byte))
- log.PanicIf(err)
- case string:
- ed, err = ve.encodeAscii(value.(string))
- log.PanicIf(err)
- case []uint16:
- ed, err = ve.encodeShorts(value.([]uint16))
- log.PanicIf(err)
- case []uint32:
- ed, err = ve.encodeLongs(value.([]uint32))
- log.PanicIf(err)
- case []Rational:
- ed, err = ve.encodeRationals(value.([]Rational))
- log.PanicIf(err)
- case []int32:
- ed, err = ve.encodeSignedLongs(value.([]int32))
- log.PanicIf(err)
- case []SignedRational:
- ed, err = ve.encodeSignedRationals(value.([]SignedRational))
- log.PanicIf(err)
- case time.Time:
- // For convenience, if the user doesn't want to deal with translation
- // semantics with timestamps.
-
- t := value.(time.Time)
- s := ExifFullTimestampString(t)
-
- ed, err = ve.encodeAscii(s)
- log.PanicIf(err)
- default:
- log.Panicf("value not encodable: [%s] [%v]", reflect.TypeOf(value), value)
- }
-
- return ed, nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/error.go b/vendor/github.com/dsoprea/go-exif/v2/error.go
deleted file mode 100644
index 2f00b08a4..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/error.go
+++ /dev/null
@@ -1,14 +0,0 @@
-package exif
-
-import (
- "errors"
-)
-
-var (
- // ErrTagNotFound indicates that the tag was not found.
- ErrTagNotFound = errors.New("tag not found")
-
- // ErrTagNotKnown indicates that the tag is not registered with us as a
- // known tag.
- ErrTagNotKnown = errors.New("tag is not known")
-)
diff --git a/vendor/github.com/dsoprea/go-exif/v2/exif.go b/vendor/github.com/dsoprea/go-exif/v2/exif.go
deleted file mode 100644
index 20b723769..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/exif.go
+++ /dev/null
@@ -1,258 +0,0 @@
-package exif
-
-import (
- "bufio"
- "bytes"
- "errors"
- "fmt"
- "io"
- "os"
-
- "encoding/binary"
- "io/ioutil"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-const (
- // ExifAddressableAreaStart is the absolute offset in the file that all
- // offsets are relative to.
- ExifAddressableAreaStart = uint32(0x0)
-
- // ExifDefaultFirstIfdOffset is essentially the number of bytes in addition
- // to `ExifAddressableAreaStart` that you have to move in order to escape
- // the rest of the header and get to the earliest point where we can put
- // stuff (which has to be the first IFD). This is the size of the header
- // sequence containing the two-character byte-order, two-character fixed-
- // bytes, and the four bytes describing the first-IFD offset.
- ExifDefaultFirstIfdOffset = uint32(2 + 2 + 4)
-)
-
-const (
- // ExifSignatureLength is the number of bytes in the EXIF signature (which
- // customarily includes the first IFD offset).
- ExifSignatureLength = 8
-)
-
-var (
- exifLogger = log.NewLogger("exif.exif")
-
- ExifBigEndianSignature = [4]byte{'M', 'M', 0x00, 0x2a}
- ExifLittleEndianSignature = [4]byte{'I', 'I', 0x2a, 0x00}
-)
-
-var (
- ErrNoExif = errors.New("no exif data")
- ErrExifHeaderError = errors.New("exif header error")
-)
-
-// SearchAndExtractExif searches for an EXIF blob in the byte-slice.
-func SearchAndExtractExif(data []byte) (rawExif []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- b := bytes.NewBuffer(data)
-
- rawExif, err = SearchAndExtractExifWithReader(b)
- if err != nil {
- if err == ErrNoExif {
- return nil, err
- }
-
- log.Panic(err)
- }
-
- return rawExif, nil
-}
-
-// SearchAndExtractExifWithReader searches for an EXIF blob using an
-// `io.Reader`. We can't know how much long the EXIF data is without parsing it,
-// so this will likely grab up a lot of the image-data, too.
-func SearchAndExtractExifWithReader(r io.Reader) (rawExif []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Search for the beginning of the EXIF information. The EXIF is near the
- // beginning of most JPEGs, so this likely doesn't have a high cost (at
- // least, again, with JPEGs).
-
- br := bufio.NewReader(r)
- discarded := 0
-
- for {
- window, err := br.Peek(ExifSignatureLength)
- if err != nil {
- if err == io.EOF {
- return nil, ErrNoExif
- }
-
- log.Panic(err)
- }
-
- _, err = ParseExifHeader(window)
- if err != nil {
- if log.Is(err, ErrNoExif) == true {
- // No EXIF. Move forward by one byte.
-
- _, err := br.Discard(1)
- log.PanicIf(err)
-
- discarded++
-
- continue
- }
-
- // Some other error.
- log.Panic(err)
- }
-
- break
- }
-
- exifLogger.Debugf(nil, "Found EXIF blob (%d) bytes from initial position.", discarded)
-
- rawExif, err = ioutil.ReadAll(br)
- log.PanicIf(err)
-
- return rawExif, nil
-}
-
-// SearchFileAndExtractExif returns a slice from the beginning of the EXIF data
-// to the end of the file (it's not practical to try and calculate where the
-// data actually ends).
-func SearchFileAndExtractExif(filepath string) (rawExif []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Open the file.
-
- f, err := os.Open(filepath)
- log.PanicIf(err)
-
- defer f.Close()
-
- rawExif, err = SearchAndExtractExifWithReader(f)
- log.PanicIf(err)
-
- return rawExif, nil
-}
-
-type ExifHeader struct {
- ByteOrder binary.ByteOrder
- FirstIfdOffset uint32
-}
-
-func (eh ExifHeader) String() string {
- return fmt.Sprintf("ExifHeader<BYTE-ORDER=[%v] FIRST-IFD-OFFSET=(0x%02x)>", eh.ByteOrder, eh.FirstIfdOffset)
-}
-
-// ParseExifHeader parses the bytes at the very top of the header.
-//
-// This will panic with ErrNoExif on any data errors so that we can double as
-// an EXIF-detection routine.
-func ParseExifHeader(data []byte) (eh ExifHeader, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Good reference:
- //
- // CIPA DC-008-2016; JEITA CP-3451D
- // -> http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf
-
- if len(data) < ExifSignatureLength {
- exifLogger.Warningf(nil, "Not enough data for EXIF header: (%d)", len(data))
- return eh, ErrNoExif
- }
-
- if bytes.Equal(data[:4], ExifBigEndianSignature[:]) == true {
- eh.ByteOrder = binary.BigEndian
- } else if bytes.Equal(data[:4], ExifLittleEndianSignature[:]) == true {
- eh.ByteOrder = binary.LittleEndian
- } else {
- return eh, ErrNoExif
- }
-
- eh.FirstIfdOffset = eh.ByteOrder.Uint32(data[4:8])
-
- return eh, nil
-}
-
-// Visit recursively invokes a callback for every tag.
-func Visit(rootIfdIdentity *exifcommon.IfdIdentity, ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, exifData []byte, visitor TagVisitorFn) (eh ExifHeader, furthestOffset uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- eh, err = ParseExifHeader(exifData)
- log.PanicIf(err)
-
- ie := NewIfdEnumerate(ifdMapping, tagIndex, exifData, eh.ByteOrder)
-
- _, err = ie.Scan(rootIfdIdentity, eh.FirstIfdOffset, visitor)
- log.PanicIf(err)
-
- furthestOffset = ie.FurthestOffset()
-
- return eh, furthestOffset, nil
-}
-
-// Collect recursively builds a static structure of all IFDs and tags.
-func Collect(ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, exifData []byte) (eh ExifHeader, index IfdIndex, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- eh, err = ParseExifHeader(exifData)
- log.PanicIf(err)
-
- ie := NewIfdEnumerate(ifdMapping, tagIndex, exifData, eh.ByteOrder)
-
- index, err = ie.Collect(eh.FirstIfdOffset)
- log.PanicIf(err)
-
- return eh, index, nil
-}
-
-// BuildExifHeader constructs the bytes that go at the front of the stream.
-func BuildExifHeader(byteOrder binary.ByteOrder, firstIfdOffset uint32) (headerBytes []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- b := new(bytes.Buffer)
-
- var signatureBytes []byte
- if byteOrder == binary.BigEndian {
- signatureBytes = ExifBigEndianSignature[:]
- } else {
- signatureBytes = ExifLittleEndianSignature[:]
- }
-
- _, err = b.Write(signatureBytes)
- log.PanicIf(err)
-
- err = binary.Write(b, byteOrder, firstIfdOffset)
- log.PanicIf(err)
-
- return b.Bytes(), nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/gps.go b/vendor/github.com/dsoprea/go-exif/v2/gps.go
deleted file mode 100644
index d44ede1ad..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/gps.go
+++ /dev/null
@@ -1,117 +0,0 @@
-package exif
-
-import (
- "errors"
- "fmt"
- "time"
-
- "github.com/dsoprea/go-logging"
- "github.com/golang/geo/s2"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-var (
- // ErrGpsCoordinatesNotValid means that some part of the geographic data was
- // unparseable.
- ErrGpsCoordinatesNotValid = errors.New("GPS coordinates not valid")
-)
-
-// GpsDegrees is a high-level struct representing geographic data.
-type GpsDegrees struct {
- // Orientation describes the N/E/S/W direction that this position is
- // relative to.
- Orientation byte
-
- // Degrees is a simple float representing the underlying rational degrees
- // amount.
- Degrees float64
-
- // Minutes is a simple float representing the underlying rational minutes
- // amount.
- Minutes float64
-
- // Seconds is a simple float representing the underlying ration seconds
- // amount.
- Seconds float64
-}
-
-// NewGpsDegreesFromRationals returns a GpsDegrees struct given the EXIF-encoded
-// information. The refValue is the N/E/S/W direction that this position is
-// relative to.
-func NewGpsDegreesFromRationals(refValue string, rawCoordinate []exifcommon.Rational) (gd GpsDegrees, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if len(rawCoordinate) != 3 {
- log.Panicf("new GpsDegrees struct requires a raw-coordinate with exactly three rationals")
- }
-
- gd = GpsDegrees{
- Orientation: refValue[0],
- Degrees: float64(rawCoordinate[0].Numerator) / float64(rawCoordinate[0].Denominator),
- Minutes: float64(rawCoordinate[1].Numerator) / float64(rawCoordinate[1].Denominator),
- Seconds: float64(rawCoordinate[2].Numerator) / float64(rawCoordinate[2].Denominator),
- }
-
- return gd, nil
-}
-
-// String provides returns a descriptive string.
-func (d GpsDegrees) String() string {
- return fmt.Sprintf("Degrees<O=[%s] D=(%g) M=(%g) S=(%g)>", string([]byte{d.Orientation}), d.Degrees, d.Minutes, d.Seconds)
-}
-
-// Decimal calculates and returns the simplified float representation of the
-// component degrees.
-func (d GpsDegrees) Decimal() float64 {
- decimal := float64(d.Degrees) + float64(d.Minutes)/60.0 + float64(d.Seconds)/3600.0
-
- if d.Orientation == 'S' || d.Orientation == 'W' {
- return -decimal
- }
-
- return decimal
-}
-
-// Raw returns a Rational struct that can be used to *write* coordinates. In
-// practice, the denominator are typically (1) in the original EXIF data, and,
-// that being the case, this will best preserve precision.
-func (d GpsDegrees) Raw() []exifcommon.Rational {
- return []exifcommon.Rational{
- {Numerator: uint32(d.Degrees), Denominator: 1},
- {Numerator: uint32(d.Minutes), Denominator: 1},
- {Numerator: uint32(d.Seconds), Denominator: 1},
- }
-}
-
-// GpsInfo encapsulates all of the geographic information in one place.
-type GpsInfo struct {
- Latitude, Longitude GpsDegrees
- Altitude int
- Timestamp time.Time
-}
-
-// String returns a descriptive string.
-func (gi *GpsInfo) String() string {
- return fmt.Sprintf("GpsInfo<LAT=(%.05f) LON=(%.05f) ALT=(%d) TIME=[%s]>",
- gi.Latitude.Decimal(), gi.Longitude.Decimal(), gi.Altitude, gi.Timestamp)
-}
-
-// S2CellId returns the cell-ID of the geographic location on the earth.
-func (gi *GpsInfo) S2CellId() s2.CellID {
- latitude := gi.Latitude.Decimal()
- longitude := gi.Longitude.Decimal()
-
- ll := s2.LatLngFromDegrees(latitude, longitude)
- cellId := s2.CellIDFromLatLng(ll)
-
- if cellId.IsValid() == false {
- panic(ErrGpsCoordinatesNotValid)
- }
-
- return cellId
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/ifd.go b/vendor/github.com/dsoprea/go-exif/v2/ifd.go
deleted file mode 100644
index 80872e624..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/ifd.go
+++ /dev/null
@@ -1,34 +0,0 @@
-package exif
-
-import (
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-// TODO(dustin): This file now exists for backwards-compatibility only.
-
-// NewIfdMapping returns a new IfdMapping struct.
-func NewIfdMapping() (ifdMapping *exifcommon.IfdMapping) {
- return exifcommon.NewIfdMapping()
-}
-
-// NewIfdMappingWithStandard retruns a new IfdMapping struct preloaded with the
-// standard IFDs.
-func NewIfdMappingWithStandard() (ifdMapping *exifcommon.IfdMapping) {
- return exifcommon.NewIfdMappingWithStandard()
-}
-
-// LoadStandardIfds loads the standard IFDs into the mapping.
-func LoadStandardIfds(im *exifcommon.IfdMapping) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = exifcommon.LoadStandardIfds(im)
- log.PanicIf(err)
-
- return nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/ifd_builder.go b/vendor/github.com/dsoprea/go-exif/v2/ifd_builder.go
deleted file mode 100644
index 64a09299c..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/ifd_builder.go
+++ /dev/null
@@ -1,1199 +0,0 @@
-package exif
-
-// NOTES:
-//
-// The thumbnail offset and length tags shouldn't be set directly. Use the
-// (*IfdBuilder).SetThumbnail() method instead.
-
-import (
- "errors"
- "fmt"
- "strings"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
- "github.com/dsoprea/go-exif/v2/undefined"
-)
-
-var (
- ifdBuilderLogger = log.NewLogger("exif.ifd_builder")
-)
-
-var (
- ErrTagEntryNotFound = errors.New("tag entry not found")
- ErrChildIbNotFound = errors.New("child IB not found")
-)
-
-type IfdBuilderTagValue struct {
- valueBytes []byte
- ib *IfdBuilder
-}
-
-func (ibtv IfdBuilderTagValue) String() string {
- if ibtv.IsBytes() == true {
- var valuePhrase string
- if len(ibtv.valueBytes) <= 8 {
- valuePhrase = fmt.Sprintf("%v", ibtv.valueBytes)
- } else {
- valuePhrase = fmt.Sprintf("%v...", ibtv.valueBytes[:8])
- }
-
- return fmt.Sprintf("IfdBuilderTagValue<BYTES=%v LEN=(%d)>", valuePhrase, len(ibtv.valueBytes))
- } else if ibtv.IsIb() == true {
- return fmt.Sprintf("IfdBuilderTagValue<IB=%s>", ibtv.ib)
- } else {
- log.Panicf("IBTV state undefined")
- return ""
- }
-}
-
-func NewIfdBuilderTagValueFromBytes(valueBytes []byte) *IfdBuilderTagValue {
- return &IfdBuilderTagValue{
- valueBytes: valueBytes,
- }
-}
-
-func NewIfdBuilderTagValueFromIfdBuilder(ib *IfdBuilder) *IfdBuilderTagValue {
- return &IfdBuilderTagValue{
- ib: ib,
- }
-}
-
-// IsBytes returns true if the bytes are populated. This is always the case
-// when we're loaded from a tag in an existing IFD.
-func (ibtv IfdBuilderTagValue) IsBytes() bool {
- return ibtv.valueBytes != nil
-}
-
-func (ibtv IfdBuilderTagValue) Bytes() []byte {
- if ibtv.IsBytes() == false {
- log.Panicf("this tag is not a byte-slice value")
- } else if ibtv.IsIb() == true {
- log.Panicf("this tag is an IFD-builder value not a byte-slice")
- }
-
- return ibtv.valueBytes
-}
-
-func (ibtv IfdBuilderTagValue) IsIb() bool {
- return ibtv.ib != nil
-}
-
-func (ibtv IfdBuilderTagValue) Ib() *IfdBuilder {
- if ibtv.IsIb() == false {
- log.Panicf("this tag is not an IFD-builder value")
- } else if ibtv.IsBytes() == true {
- log.Panicf("this tag is a byte-slice, not a IFD-builder")
- }
-
- return ibtv.ib
-}
-
-type BuilderTag struct {
- // ifdPath is the path of the IFD that hosts this tag.
- ifdPath string
-
- tagId uint16
- typeId exifcommon.TagTypePrimitive
-
- // value is either a value that can be encoded, an IfdBuilder instance (for
- // child IFDs), or an IfdTagEntry instance representing an existing,
- // previously-stored tag.
- value *IfdBuilderTagValue
-
- // byteOrder is the byte order. It's chiefly/originally here to support
- // printing the value.
- byteOrder binary.ByteOrder
-}
-
-func NewBuilderTag(ifdPath string, tagId uint16, typeId exifcommon.TagTypePrimitive, value *IfdBuilderTagValue, byteOrder binary.ByteOrder) *BuilderTag {
- return &BuilderTag{
- ifdPath: ifdPath,
- tagId: tagId,
- typeId: typeId,
- value: value,
- byteOrder: byteOrder,
- }
-}
-
-func NewChildIfdBuilderTag(ifdPath string, tagId uint16, value *IfdBuilderTagValue) *BuilderTag {
- return &BuilderTag{
- ifdPath: ifdPath,
- tagId: tagId,
- typeId: exifcommon.TypeLong,
- value: value,
- }
-}
-
-func (bt *BuilderTag) Value() (value *IfdBuilderTagValue) {
- return bt.value
-}
-
-func (bt *BuilderTag) String() string {
- var valueString string
-
- if bt.value.IsBytes() == true {
- var err error
-
- valueString, err = exifcommon.FormatFromBytes(bt.value.Bytes(), bt.typeId, false, bt.byteOrder)
- log.PanicIf(err)
- } else {
- valueString = fmt.Sprintf("%v", bt.value)
- }
-
- return fmt.Sprintf("BuilderTag<IFD-PATH=[%s] TAG-ID=(0x%04x) TAG-TYPE=[%s] VALUE=[%s]>", bt.ifdPath, bt.tagId, bt.typeId.String(), valueString)
-}
-
-func (bt *BuilderTag) SetValue(byteOrder binary.ByteOrder, value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test.
-
- var ed exifcommon.EncodedData
- if bt.typeId == exifcommon.TypeUndefined {
- encodeable := value.(exifundefined.EncodeableValue)
-
- encoded, unitCount, err := exifundefined.Encode(encodeable, byteOrder)
- log.PanicIf(err)
-
- ed = exifcommon.EncodedData{
- Type: exifcommon.TypeUndefined,
- Encoded: encoded,
- UnitCount: unitCount,
- }
- } else {
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- var err error
-
- ed, err = ve.Encode(value)
- log.PanicIf(err)
- }
-
- bt.value = NewIfdBuilderTagValueFromBytes(ed.Encoded)
-
- return nil
-}
-
-// NewStandardBuilderTag constructs a `BuilderTag` instance. The type is looked
-// up. `ii` is the type of IFD that owns this tag.
-func NewStandardBuilderTag(ifdPath string, it *IndexedTag, byteOrder binary.ByteOrder, value interface{}) *BuilderTag {
- // If there is more than one supported type, we'll go with the larger to
- // encode with. It'll use the same amount of fixed-space, and we'll
- // eliminate unnecessary overflows/issues.
- tagType := it.GetEncodingType(value)
-
- var rawBytes []byte
- if it.DoesSupportType(exifcommon.TypeUndefined) == true {
- encodeable := value.(exifundefined.EncodeableValue)
-
- var err error
-
- rawBytes, _, err = exifundefined.Encode(encodeable, byteOrder)
- log.PanicIf(err)
- } else {
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- ed, err := ve.Encode(value)
- log.PanicIf(err)
-
- rawBytes = ed.Encoded
- }
-
- tagValue := NewIfdBuilderTagValueFromBytes(rawBytes)
-
- return NewBuilderTag(
- ifdPath,
- it.Id,
- tagType,
- tagValue,
- byteOrder)
-}
-
-type IfdBuilder struct {
- ifdIdentity *exifcommon.IfdIdentity
-
- byteOrder binary.ByteOrder
-
- // Includes both normal tags and IFD tags (which point to child IFDs).
- // TODO(dustin): Keep a separate list of children like with `Ifd`.
- // TODO(dustin): Either rename this or `Entries` in `Ifd` to be the same thing.
- tags []*BuilderTag
-
- // existingOffset will be the offset that this IFD is currently found at if
- // it represents an IFD that has previously been stored (or 0 if not).
- existingOffset uint32
-
- // nextIb represents the next link if we're chaining to another.
- nextIb *IfdBuilder
-
- // thumbnailData is populated with thumbnail data if there was thumbnail
- // data. Otherwise, it's nil.
- thumbnailData []byte
-
- ifdMapping *exifcommon.IfdMapping
- tagIndex *TagIndex
-}
-
-func NewIfdBuilder(ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, ii *exifcommon.IfdIdentity, byteOrder binary.ByteOrder) (ib *IfdBuilder) {
- ib = &IfdBuilder{
- ifdIdentity: ii,
-
- byteOrder: byteOrder,
- tags: make([]*BuilderTag, 0),
-
- ifdMapping: ifdMapping,
- tagIndex: tagIndex,
- }
-
- return ib
-}
-
-// NewIfdBuilderWithExistingIfd creates a new IB using the same header type
-// information as the given IFD.
-func NewIfdBuilderWithExistingIfd(ifd *Ifd) (ib *IfdBuilder) {
- ib = &IfdBuilder{
- ifdIdentity: ifd.IfdIdentity(),
-
- byteOrder: ifd.ByteOrder,
- existingOffset: ifd.Offset,
- ifdMapping: ifd.ifdMapping,
- tagIndex: ifd.tagIndex,
- }
-
- return ib
-}
-
-// NewIfdBuilderFromExistingChain creates a chain of IB instances from an
-// IFD chain generated from real data.
-func NewIfdBuilderFromExistingChain(rootIfd *Ifd) (firstIb *IfdBuilder) {
- var lastIb *IfdBuilder
- i := 0
- for thisExistingIfd := rootIfd; thisExistingIfd != nil; thisExistingIfd = thisExistingIfd.NextIfd {
- newIb := NewIfdBuilder(
- rootIfd.ifdMapping,
- rootIfd.tagIndex,
- rootIfd.ifdIdentity,
- thisExistingIfd.ByteOrder)
-
- if firstIb == nil {
- firstIb = newIb
- } else {
- lastIb.SetNextIb(newIb)
- }
-
- err := newIb.AddTagsFromExisting(thisExistingIfd, nil, nil)
- log.PanicIf(err)
-
- lastIb = newIb
- i++
- }
-
- return firstIb
-}
-
-func (ib *IfdBuilder) IfdIdentity() *exifcommon.IfdIdentity {
- return ib.ifdIdentity
-}
-
-func (ib *IfdBuilder) NextIb() (nextIb *IfdBuilder, err error) {
- return ib.nextIb, nil
-}
-
-func (ib *IfdBuilder) ChildWithTagId(childIfdTagId uint16) (childIb *IfdBuilder, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- for _, bt := range ib.tags {
- if bt.value.IsIb() == false {
- continue
- }
-
- childIbThis := bt.value.Ib()
-
- if childIbThis.IfdIdentity().TagId() == childIfdTagId {
- return childIbThis, nil
- }
- }
-
- log.Panic(ErrChildIbNotFound)
-
- // Never reached.
- return nil, nil
-}
-
-func getOrCreateIbFromRootIbInner(rootIb *IfdBuilder, parentIb *IfdBuilder, currentLineage []exifcommon.IfdTagIdAndIndex) (ib *IfdBuilder, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test.
-
- thisIb := rootIb
-
- // Since we're calling ourselves recursively with incrementally different
- // paths, the FQ IFD-path of the parent that called us needs to be passed
- // in, in order for us to know it.
- var parentLineage []exifcommon.IfdTagIdAndIndex
- if parentIb != nil {
- var err error
-
- parentLineage, err = thisIb.ifdMapping.ResolvePath(parentIb.IfdIdentity().String())
- log.PanicIf(err)
- }
-
- // Process the current path part.
- currentItIi := currentLineage[0]
-
- // Make sure the leftmost part of the FQ IFD-path agrees with the IB we
- // were given.
-
- expectedFqRootIfdPath := ""
- if parentLineage != nil {
- expectedLineage := append(parentLineage, currentItIi)
- expectedFqRootIfdPath = thisIb.ifdMapping.PathPhraseFromLineage(expectedLineage)
- } else {
- expectedFqRootIfdPath = thisIb.ifdMapping.PathPhraseFromLineage(currentLineage[:1])
- }
-
- if expectedFqRootIfdPath != thisIb.IfdIdentity().String() {
- log.Panicf("the FQ IFD-path [%s] we were given does not match the builder's FQ IFD-path [%s]", expectedFqRootIfdPath, thisIb.IfdIdentity().String())
- }
-
- // If we actually wanted a sibling (currentItIi.Index > 0) then seek to it,
- // appending new siblings, as required, until we get there.
- for i := 0; i < currentItIi.Index; i++ {
- if thisIb.nextIb == nil {
- // Generate an FQ IFD-path for the sibling. It'll use the same
- // non-FQ IFD-path as the current IB.
-
- iiSibling := thisIb.IfdIdentity().NewSibling(i + 1)
- thisIb.nextIb = NewIfdBuilder(thisIb.ifdMapping, thisIb.tagIndex, iiSibling, thisIb.byteOrder)
- }
-
- thisIb = thisIb.nextIb
- }
-
- // There is no child IFD to process. We're done.
- if len(currentLineage) == 1 {
- return thisIb, nil
- }
-
- // Establish the next child to be processed.
-
- childItii := currentLineage[1]
-
- var foundChild *IfdBuilder
- for _, bt := range thisIb.tags {
- if bt.value.IsIb() == false {
- continue
- }
-
- childIb := bt.value.Ib()
-
- if childIb.IfdIdentity().TagId() == childItii.TagId {
- foundChild = childIb
- break
- }
- }
-
- // If we didn't find the child, add it.
-
- if foundChild == nil {
- currentIfdTag := thisIb.IfdIdentity().IfdTag()
-
- childIfdTag :=
- exifcommon.NewIfdTag(
- &currentIfdTag,
- childItii.TagId,
- childItii.Name)
-
- iiChild := thisIb.IfdIdentity().NewChild(childIfdTag, 0)
-
- foundChild =
- NewIfdBuilder(
- thisIb.ifdMapping,
- thisIb.tagIndex,
- iiChild,
- thisIb.byteOrder)
-
- err = thisIb.AddChildIb(foundChild)
- log.PanicIf(err)
- }
-
- finalIb, err := getOrCreateIbFromRootIbInner(foundChild, thisIb, currentLineage[1:])
- log.PanicIf(err)
-
- return finalIb, nil
-}
-
-// GetOrCreateIbFromRootIb returns an IB representing the requested IFD, even if
-// an IB doesn't already exist for it. This function may call itself
-// recursively.
-func GetOrCreateIbFromRootIb(rootIb *IfdBuilder, fqIfdPath string) (ib *IfdBuilder, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // lineage is a necessity of our recursion process. It doesn't include any
- // parent IFDs on its left-side; it starts with the current IB only.
- lineage, err := rootIb.ifdMapping.ResolvePath(fqIfdPath)
- log.PanicIf(err)
-
- ib, err = getOrCreateIbFromRootIbInner(rootIb, nil, lineage)
- log.PanicIf(err)
-
- return ib, nil
-}
-
-func (ib *IfdBuilder) String() string {
- nextIfdPhrase := ""
- if ib.nextIb != nil {
- // TODO(dustin): We were setting this to ii.String(), but we were getting hex-data when printing this after building from an existing chain.
- nextIfdPhrase = ib.nextIb.IfdIdentity().UnindexedString()
- }
-
- return fmt.Sprintf("IfdBuilder<PATH=[%s] TAG-ID=(0x%04x) COUNT=(%d) OFF=(0x%04x) NEXT-IFD-PATH=[%s]>", ib.IfdIdentity().UnindexedString(), ib.IfdIdentity().TagId(), len(ib.tags), ib.existingOffset, nextIfdPhrase)
-}
-
-func (ib *IfdBuilder) Tags() (tags []*BuilderTag) {
- return ib.tags
-}
-
-// SetThumbnail sets thumbnail data.
-//
-// NOTES:
-//
-// - We don't manage any facet of the thumbnail data. This is the
-// responsibility of the user/developer.
-// - This method will fail unless the thumbnail is set on a the root IFD.
-// However, in order to be valid, it must be set on the second one, linked to
-// by the first, as per the EXIF/TIFF specification.
-// - We set the offset to (0) now but will allocate the data and properly assign
-// the offset when the IB is encoded (later).
-func (ib *IfdBuilder) SetThumbnail(data []byte) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if ib.IfdIdentity().UnindexedString() != exifcommon.IfdStandardIfdIdentity.UnindexedString() {
- log.Panicf("thumbnails can only go into a root Ifd (and only the second one)")
- }
-
- // TODO(dustin): !! Add a test for this function.
-
- if data == nil || len(data) == 0 {
- log.Panic("thumbnail is empty")
- }
-
- ib.thumbnailData = data
-
- ibtvfb := NewIfdBuilderTagValueFromBytes(ib.thumbnailData)
- offsetBt :=
- NewBuilderTag(
- ib.IfdIdentity().UnindexedString(),
- ThumbnailOffsetTagId,
- exifcommon.TypeLong,
- ibtvfb,
- ib.byteOrder)
-
- err = ib.Set(offsetBt)
- log.PanicIf(err)
-
- thumbnailSizeIt, err := ib.tagIndex.Get(ib.IfdIdentity(), ThumbnailSizeTagId)
- log.PanicIf(err)
-
- sizeBt := NewStandardBuilderTag(ib.IfdIdentity().UnindexedString(), thumbnailSizeIt, ib.byteOrder, []uint32{uint32(len(ib.thumbnailData))})
-
- err = ib.Set(sizeBt)
- log.PanicIf(err)
-
- return nil
-}
-
-func (ib *IfdBuilder) Thumbnail() []byte {
- return ib.thumbnailData
-}
-
-func (ib *IfdBuilder) printTagTree(levels int) {
- indent := strings.Repeat(" ", levels*2)
-
- i := 0
- for currentIb := ib; currentIb != nil; currentIb = currentIb.nextIb {
- prefix := " "
- if i > 0 {
- prefix = ">"
- }
-
- if levels == 0 {
- fmt.Printf("%s%sIFD: %s INDEX=(%d)\n", indent, prefix, currentIb, i)
- } else {
- fmt.Printf("%s%sChild IFD: %s\n", indent, prefix, currentIb)
- }
-
- if len(currentIb.tags) > 0 {
- fmt.Printf("\n")
-
- for i, tag := range currentIb.tags {
- isChildIb := false
- _, err := ib.ifdMapping.GetChild(currentIb.IfdIdentity().UnindexedString(), tag.tagId)
- if err == nil {
- isChildIb = true
- } else if log.Is(err, exifcommon.ErrChildIfdNotMapped) == false {
- log.Panic(err)
- }
-
- tagName := ""
-
- // If a normal tag (not a child IFD) get the name.
- if isChildIb == true {
- tagName = "<Child IFD>"
- } else {
- it, err := ib.tagIndex.Get(ib.ifdIdentity, tag.tagId)
- if log.Is(err, ErrTagNotFound) == true {
- tagName = "<UNKNOWN>"
- } else if err != nil {
- log.Panic(err)
- } else {
- tagName = it.Name
- }
- }
-
- value := tag.Value()
-
- if value.IsIb() == true {
- fmt.Printf("%s (%d): [%s] %s\n", indent, i, tagName, value.Ib())
- } else {
- fmt.Printf("%s (%d): [%s] %s\n", indent, i, tagName, tag)
- }
-
- if isChildIb == true {
- if tag.value.IsIb() == false {
- log.Panicf("tag-ID (0x%04x) is an IFD but the tag value is not an IB instance: %v", tag.tagId, tag)
- }
-
- fmt.Printf("\n")
-
- childIb := tag.value.Ib()
- childIb.printTagTree(levels + 1)
- }
- }
-
- fmt.Printf("\n")
- }
-
- i++
- }
-}
-
-func (ib *IfdBuilder) PrintTagTree() {
- ib.printTagTree(0)
-}
-
-func (ib *IfdBuilder) printIfdTree(levels int) {
- indent := strings.Repeat(" ", levels*2)
-
- i := 0
- for currentIb := ib; currentIb != nil; currentIb = currentIb.nextIb {
- prefix := " "
- if i > 0 {
- prefix = ">"
- }
-
- fmt.Printf("%s%s%s\n", indent, prefix, currentIb)
-
- if len(currentIb.tags) > 0 {
- for _, tag := range currentIb.tags {
- isChildIb := false
- _, err := ib.ifdMapping.GetChild(currentIb.IfdIdentity().UnindexedString(), tag.tagId)
- if err == nil {
- isChildIb = true
- } else if log.Is(err, exifcommon.ErrChildIfdNotMapped) == false {
- log.Panic(err)
- }
-
- if isChildIb == true {
- if tag.value.IsIb() == false {
- log.Panicf("tag-ID (0x%04x) is an IFD but the tag value is not an IB instance: %v", tag.tagId, tag)
- }
-
- childIb := tag.value.Ib()
- childIb.printIfdTree(levels + 1)
- }
- }
- }
-
- i++
- }
-}
-
-func (ib *IfdBuilder) PrintIfdTree() {
- ib.printIfdTree(0)
-}
-
-func (ib *IfdBuilder) dumpToStrings(thisIb *IfdBuilder, prefix string, tagId uint16, lines []string) (linesOutput []string) {
- if lines == nil {
- linesOutput = make([]string, 0)
- } else {
- linesOutput = lines
- }
-
- siblingIfdIndex := 0
- for ; thisIb != nil; thisIb = thisIb.nextIb {
- line := fmt.Sprintf("IFD<PARENTS=[%s] FQ-IFD-PATH=[%s] IFD-INDEX=(%d) IFD-TAG-ID=(0x%04x) TAG=[0x%04x]>", prefix, thisIb.IfdIdentity().String(), siblingIfdIndex, thisIb.IfdIdentity().TagId(), tagId)
- linesOutput = append(linesOutput, line)
-
- for i, tag := range thisIb.tags {
- var childIb *IfdBuilder
- childIfdName := ""
- if tag.value.IsIb() == true {
- childIb = tag.value.Ib()
- childIfdName = childIb.IfdIdentity().UnindexedString()
- }
-
- line := fmt.Sprintf("TAG<PARENTS=[%s] FQ-IFD-PATH=[%s] IFD-TAG-ID=(0x%04x) CHILD-IFD=[%s] TAG-INDEX=(%d) TAG=[0x%04x]>", prefix, thisIb.IfdIdentity().String(), thisIb.IfdIdentity().TagId(), childIfdName, i, tag.tagId)
- linesOutput = append(linesOutput, line)
-
- if childIb == nil {
- continue
- }
-
- childPrefix := ""
- if prefix == "" {
- childPrefix = fmt.Sprintf("%s", thisIb.IfdIdentity().UnindexedString())
- } else {
- childPrefix = fmt.Sprintf("%s->%s", prefix, thisIb.IfdIdentity().UnindexedString())
- }
-
- linesOutput = thisIb.dumpToStrings(childIb, childPrefix, tag.tagId, linesOutput)
- }
-
- siblingIfdIndex++
- }
-
- return linesOutput
-}
-
-func (ib *IfdBuilder) DumpToStrings() (lines []string) {
- return ib.dumpToStrings(ib, "", 0, lines)
-}
-
-func (ib *IfdBuilder) SetNextIb(nextIb *IfdBuilder) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ib.nextIb = nextIb
-
- return nil
-}
-
-func (ib *IfdBuilder) DeleteN(tagId uint16, n int) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if n < 1 {
- log.Panicf("N must be at least 1: (%d)", n)
- }
-
- for n > 0 {
- j := -1
- for i, bt := range ib.tags {
- if bt.tagId == tagId {
- j = i
- break
- }
- }
-
- if j == -1 {
- log.Panic(ErrTagEntryNotFound)
- }
-
- ib.tags = append(ib.tags[:j], ib.tags[j+1:]...)
- n--
- }
-
- return nil
-}
-
-func (ib *IfdBuilder) DeleteFirst(tagId uint16) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = ib.DeleteN(tagId, 1)
- log.PanicIf(err)
-
- return nil
-}
-
-func (ib *IfdBuilder) DeleteAll(tagId uint16) (n int, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- for {
- err = ib.DeleteN(tagId, 1)
- if log.Is(err, ErrTagEntryNotFound) == true {
- break
- } else if err != nil {
- log.Panic(err)
- }
-
- n++
- }
-
- return n, nil
-}
-
-func (ib *IfdBuilder) ReplaceAt(position int, bt *BuilderTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if position < 0 {
- log.Panicf("replacement position must be 0 or greater")
- } else if position >= len(ib.tags) {
- log.Panicf("replacement position does not exist")
- }
-
- ib.tags[position] = bt
-
- return nil
-}
-
-func (ib *IfdBuilder) Replace(tagId uint16, bt *BuilderTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- position, err := ib.Find(tagId)
- log.PanicIf(err)
-
- ib.tags[position] = bt
-
- return nil
-}
-
-// Set will add a new entry or update an existing entry.
-func (ib *IfdBuilder) Set(bt *BuilderTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- position, err := ib.Find(bt.tagId)
- if err == nil {
- ib.tags[position] = bt
- } else if log.Is(err, ErrTagEntryNotFound) == true {
- err = ib.add(bt)
- log.PanicIf(err)
- } else {
- log.Panic(err)
- }
-
- return nil
-}
-
-func (ib *IfdBuilder) FindN(tagId uint16, maxFound int) (found []int, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- found = make([]int, 0)
-
- for i, bt := range ib.tags {
- if bt.tagId == tagId {
- found = append(found, i)
- if maxFound == 0 || len(found) >= maxFound {
- break
- }
- }
- }
-
- return found, nil
-}
-
-func (ib *IfdBuilder) Find(tagId uint16) (position int, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- found, err := ib.FindN(tagId, 1)
- log.PanicIf(err)
-
- if len(found) == 0 {
- log.Panic(ErrTagEntryNotFound)
- }
-
- return found[0], nil
-}
-
-func (ib *IfdBuilder) FindTag(tagId uint16) (bt *BuilderTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- found, err := ib.FindN(tagId, 1)
- log.PanicIf(err)
-
- if len(found) == 0 {
- log.Panic(ErrTagEntryNotFound)
- }
-
- position := found[0]
-
- return ib.tags[position], nil
-}
-
-func (ib *IfdBuilder) FindTagWithName(tagName string) (bt *BuilderTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- it, err := ib.tagIndex.GetWithName(ib.IfdIdentity(), tagName)
- log.PanicIf(err)
-
- found, err := ib.FindN(it.Id, 1)
- log.PanicIf(err)
-
- if len(found) == 0 {
- log.Panic(ErrTagEntryNotFound)
- }
-
- position := found[0]
-
- return ib.tags[position], nil
-}
-
-func (ib *IfdBuilder) add(bt *BuilderTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if bt.ifdPath == "" {
- log.Panicf("BuilderTag ifdPath is not set: %s", bt)
- } else if bt.typeId == 0x0 {
- log.Panicf("BuilderTag type-ID is not set: %s", bt)
- } else if bt.value == nil {
- log.Panicf("BuilderTag value is not set: %s", bt)
- }
-
- ib.tags = append(ib.tags, bt)
- return nil
-}
-
-func (ib *IfdBuilder) Add(bt *BuilderTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if bt.value.IsIb() == true {
- log.Panicf("child IfdBuilders must be added via AddChildIb() or AddTagsFromExisting(), not Add()")
- }
-
- err = ib.add(bt)
- log.PanicIf(err)
-
- return nil
-}
-
-// AddChildIb adds a tag that branches to a new IFD.
-func (ib *IfdBuilder) AddChildIb(childIb *IfdBuilder) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if childIb.IfdIdentity().TagId() == 0 {
- log.Panicf("IFD can not be used as a child IFD (not associated with a tag-ID): %v", childIb)
- } else if childIb.byteOrder != ib.byteOrder {
- log.Panicf("Child IFD does not have the same byte-order: [%s] != [%s]", childIb.byteOrder, ib.byteOrder)
- }
-
- // Since no standard IFDs supports occur`ring more than once, check that a
- // tag of this type has not been previously added. Note that we just search
- // the current IFD and *not every* IFD.
- for _, bt := range childIb.tags {
- if bt.tagId == childIb.IfdIdentity().TagId() {
- log.Panicf("child-IFD already added: %v", childIb.IfdIdentity().UnindexedString())
- }
- }
-
- bt := ib.NewBuilderTagFromBuilder(childIb)
- ib.tags = append(ib.tags, bt)
-
- return nil
-}
-
-func (ib *IfdBuilder) NewBuilderTagFromBuilder(childIb *IfdBuilder) (bt *BuilderTag) {
- defer func() {
- if state := recover(); state != nil {
- err := log.Wrap(state.(error))
- log.Panic(err)
- }
- }()
-
- value := NewIfdBuilderTagValueFromIfdBuilder(childIb)
-
- bt = NewChildIfdBuilderTag(
- ib.IfdIdentity().UnindexedString(),
- childIb.IfdIdentity().TagId(),
- value)
-
- return bt
-}
-
-// AddTagsFromExisting does a verbatim copy of the entries in `ifd` to this
-// builder. It excludes child IFDs. These must be added explicitly via
-// `AddChildIb()`.
-func (ib *IfdBuilder) AddTagsFromExisting(ifd *Ifd, includeTagIds []uint16, excludeTagIds []uint16) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- thumbnailData, err := ifd.Thumbnail()
- if err == nil {
- err = ib.SetThumbnail(thumbnailData)
- log.PanicIf(err)
- } else if log.Is(err, ErrNoThumbnail) == false {
- log.Panic(err)
- }
-
- for i, ite := range ifd.Entries {
- if ite.IsThumbnailOffset() == true || ite.IsThumbnailSize() {
- // These will be added on-the-fly when we encode.
- continue
- }
-
- if excludeTagIds != nil && len(excludeTagIds) > 0 {
- found := false
- for _, excludedTagId := range excludeTagIds {
- if excludedTagId == ite.TagId() {
- found = true
- }
- }
-
- if found == true {
- continue
- }
- }
-
- if includeTagIds != nil && len(includeTagIds) > 0 {
- // Whether or not there was a list of excludes, if there is a list
- // of includes than the current tag has to be in it.
-
- found := false
- for _, includedTagId := range includeTagIds {
- if includedTagId == ite.TagId() {
- found = true
- break
- }
- }
-
- if found == false {
- continue
- }
- }
-
- var bt *BuilderTag
-
- if ite.ChildIfdPath() != "" {
- // If we want to add an IFD tag, we'll have to build it first and
- // *then* add it via a different method.
-
- // Figure out which of the child-IFDs that are associated with
- // this IFD represents this specific child IFD.
-
- var childIfd *Ifd
- for _, thisChildIfd := range ifd.Children {
- if thisChildIfd.ParentTagIndex != i {
- continue
- } else if thisChildIfd.ifdIdentity.TagId() != 0xffff && thisChildIfd.ifdIdentity.TagId() != ite.TagId() {
- log.Panicf("child-IFD tag is not correct: TAG-POSITION=(%d) ITE=%s CHILD-IFD=%s", thisChildIfd.ParentTagIndex, ite, thisChildIfd)
- }
-
- childIfd = thisChildIfd
- break
- }
-
- if childIfd == nil {
- childTagIds := make([]string, len(ifd.Children))
- for j, childIfd := range ifd.Children {
- childTagIds[j] = fmt.Sprintf("0x%04x (parent tag-position %d)", childIfd.ifdIdentity.TagId(), childIfd.ParentTagIndex)
- }
-
- log.Panicf("could not find child IFD for child ITE: IFD-PATH=[%s] TAG-ID=(0x%04x) CURRENT-TAG-POSITION=(%d) CHILDREN=%v", ite.IfdPath(), ite.TagId(), i, childTagIds)
- }
-
- childIb := NewIfdBuilderFromExistingChain(childIfd)
- bt = ib.NewBuilderTagFromBuilder(childIb)
- } else {
- // Non-IFD tag.
-
- rawBytes, err := ite.GetRawBytes()
- log.PanicIf(err)
-
- value := NewIfdBuilderTagValueFromBytes(rawBytes)
-
- bt = NewBuilderTag(
- ifd.ifdIdentity.UnindexedString(),
- ite.TagId(),
- ite.TagType(),
- value,
- ib.byteOrder)
- }
-
- err := ib.add(bt)
- log.PanicIf(err)
- }
-
- return nil
-}
-
-// AddStandard quickly and easily composes and adds the tag using the
-// information already known about a tag. Only works with standard tags.
-func (ib *IfdBuilder) AddStandard(tagId uint16, value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- it, err := ib.tagIndex.Get(ib.IfdIdentity(), tagId)
- log.PanicIf(err)
-
- bt := NewStandardBuilderTag(ib.IfdIdentity().UnindexedString(), it, ib.byteOrder, value)
-
- err = ib.add(bt)
- log.PanicIf(err)
-
- return nil
-}
-
-// AddStandardWithName quickly and easily composes and adds the tag using the
-// information already known about a tag (using the name). Only works with
-// standard tags.
-func (ib *IfdBuilder) AddStandardWithName(tagName string, value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- it, err := ib.tagIndex.GetWithName(ib.IfdIdentity(), tagName)
- log.PanicIf(err)
-
- bt := NewStandardBuilderTag(ib.IfdIdentity().UnindexedString(), it, ib.byteOrder, value)
-
- err = ib.add(bt)
- log.PanicIf(err)
-
- return nil
-}
-
-// SetStandard quickly and easily composes and adds or replaces the tag using
-// the information already known about a tag. Only works with standard tags.
-func (ib *IfdBuilder) SetStandard(tagId uint16, value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test for this function.
-
- it, err := ib.tagIndex.Get(ib.IfdIdentity(), tagId)
- log.PanicIf(err)
-
- bt := NewStandardBuilderTag(ib.IfdIdentity().UnindexedString(), it, ib.byteOrder, value)
-
- i, err := ib.Find(tagId)
- if err != nil {
- if log.Is(err, ErrTagEntryNotFound) == false {
- log.Panic(err)
- }
-
- ib.tags = append(ib.tags, bt)
- } else {
- ib.tags[i] = bt
- }
-
- return nil
-}
-
-// SetStandardWithName quickly and easily composes and adds or replaces the
-// tag using the information already known about a tag (using the name). Only
-// works with standard tags.
-func (ib *IfdBuilder) SetStandardWithName(tagName string, value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test for this function.
-
- it, err := ib.tagIndex.GetWithName(ib.IfdIdentity(), tagName)
- log.PanicIf(err)
-
- bt := NewStandardBuilderTag(ib.IfdIdentity().UnindexedString(), it, ib.byteOrder, value)
-
- i, err := ib.Find(bt.tagId)
- if err != nil {
- if log.Is(err, ErrTagEntryNotFound) == false {
- log.Panic(err)
- }
-
- ib.tags = append(ib.tags, bt)
- } else {
- ib.tags[i] = bt
- }
-
- return nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/ifd_builder_encode.go b/vendor/github.com/dsoprea/go-exif/v2/ifd_builder_encode.go
deleted file mode 100644
index a0bac3e5b..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/ifd_builder_encode.go
+++ /dev/null
@@ -1,532 +0,0 @@
-package exif
-
-import (
- "bytes"
- "fmt"
- "strings"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-const (
- // Tag-ID + Tag-Type + Unit-Count + Value/Offset.
- IfdTagEntrySize = uint32(2 + 2 + 4 + 4)
-)
-
-type ByteWriter struct {
- b *bytes.Buffer
- byteOrder binary.ByteOrder
-}
-
-func NewByteWriter(b *bytes.Buffer, byteOrder binary.ByteOrder) (bw *ByteWriter) {
- return &ByteWriter{
- b: b,
- byteOrder: byteOrder,
- }
-}
-
-func (bw ByteWriter) writeAsBytes(value interface{}) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = binary.Write(bw.b, bw.byteOrder, value)
- log.PanicIf(err)
-
- return nil
-}
-
-func (bw ByteWriter) WriteUint32(value uint32) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = bw.writeAsBytes(value)
- log.PanicIf(err)
-
- return nil
-}
-
-func (bw ByteWriter) WriteUint16(value uint16) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- err = bw.writeAsBytes(value)
- log.PanicIf(err)
-
- return nil
-}
-
-func (bw ByteWriter) WriteFourBytes(value []byte) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- len_ := len(value)
- if len_ != 4 {
- log.Panicf("value is not four-bytes: (%d)", len_)
- }
-
- _, err = bw.b.Write(value)
- log.PanicIf(err)
-
- return nil
-}
-
-// ifdOffsetIterator keeps track of where the next IFD should be written by
-// keeping track of where the offsets start, the data that has been added, and
-// bumping the offset *when* the data is added.
-type ifdDataAllocator struct {
- offset uint32
- b bytes.Buffer
-}
-
-func newIfdDataAllocator(ifdDataAddressableOffset uint32) *ifdDataAllocator {
- return &ifdDataAllocator{
- offset: ifdDataAddressableOffset,
- }
-}
-
-func (ida *ifdDataAllocator) Allocate(value []byte) (offset uint32, err error) {
- _, err = ida.b.Write(value)
- log.PanicIf(err)
-
- offset = ida.offset
- ida.offset += uint32(len(value))
-
- return offset, nil
-}
-
-func (ida *ifdDataAllocator) NextOffset() uint32 {
- return ida.offset
-}
-
-func (ida *ifdDataAllocator) Bytes() []byte {
- return ida.b.Bytes()
-}
-
-// IfdByteEncoder converts an IB to raw bytes (for writing) while also figuring
-// out all of the allocations and indirection that is required for extended
-// data.
-type IfdByteEncoder struct {
- // journal holds a list of actions taken while encoding.
- journal [][3]string
-}
-
-func NewIfdByteEncoder() (ibe *IfdByteEncoder) {
- return &IfdByteEncoder{
- journal: make([][3]string, 0),
- }
-}
-
-func (ibe *IfdByteEncoder) Journal() [][3]string {
- return ibe.journal
-}
-
-func (ibe *IfdByteEncoder) TableSize(entryCount int) uint32 {
- // Tag-Count + (Entry-Size * Entry-Count) + Next-IFD-Offset.
- return uint32(2) + (IfdTagEntrySize * uint32(entryCount)) + uint32(4)
-}
-
-func (ibe *IfdByteEncoder) pushToJournal(where, direction, format string, args ...interface{}) {
- event := [3]string{
- direction,
- where,
- fmt.Sprintf(format, args...),
- }
-
- ibe.journal = append(ibe.journal, event)
-}
-
-// PrintJournal prints a hierarchical representation of the steps taken during
-// encoding.
-func (ibe *IfdByteEncoder) PrintJournal() {
- maxWhereLength := 0
- for _, event := range ibe.journal {
- where := event[1]
-
- len_ := len(where)
- if len_ > maxWhereLength {
- maxWhereLength = len_
- }
- }
-
- level := 0
- for i, event := range ibe.journal {
- direction := event[0]
- where := event[1]
- message := event[2]
-
- if direction != ">" && direction != "<" && direction != "-" {
- log.Panicf("journal operation not valid: [%s]", direction)
- }
-
- if direction == "<" {
- if level <= 0 {
- log.Panicf("journal operations unbalanced (too many closes)")
- }
-
- level--
- }
-
- indent := strings.Repeat(" ", level)
-
- fmt.Printf("%3d %s%s %s: %s\n", i, indent, direction, where, message)
-
- if direction == ">" {
- level++
- }
- }
-
- if level != 0 {
- log.Panicf("journal operations unbalanced (too many opens)")
- }
-}
-
-// encodeTagToBytes encodes the given tag to a byte stream. If
-// `nextIfdOffsetToWrite` is more than (0), recurse into child IFDs
-// (`nextIfdOffsetToWrite` is required in order for them to know where the its
-// IFD data will be written, in order for them to know the offset of where
-// their allocated-data block will start, which follows right behind).
-func (ibe *IfdByteEncoder) encodeTagToBytes(ib *IfdBuilder, bt *BuilderTag, bw *ByteWriter, ida *ifdDataAllocator, nextIfdOffsetToWrite uint32) (childIfdBlock []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Write tag-ID.
- err = bw.WriteUint16(bt.tagId)
- log.PanicIf(err)
-
- // Works for both values and child IFDs (which have an official size of
- // LONG).
- err = bw.WriteUint16(uint16(bt.typeId))
- log.PanicIf(err)
-
- // Write unit-count.
-
- if bt.value.IsBytes() == true {
- effectiveType := bt.typeId
- if bt.typeId == exifcommon.TypeUndefined {
- effectiveType = exifcommon.TypeByte
- }
-
- // It's a non-unknown value.Calculate the count of values of
- // the type that we're writing and the raw bytes for the whole list.
-
- typeSize := uint32(effectiveType.Size())
-
- valueBytes := bt.value.Bytes()
-
- len_ := len(valueBytes)
- unitCount := uint32(len_) / typeSize
-
- if _, found := tagsWithoutAlignment[bt.tagId]; found == false {
- remainder := uint32(len_) % typeSize
-
- if remainder > 0 {
- log.Panicf("tag (0x%04x) value of (%d) bytes not evenly divisible by type-size (%d)", bt.tagId, len_, typeSize)
- }
- }
-
- err = bw.WriteUint32(unitCount)
- log.PanicIf(err)
-
- // Write four-byte value/offset.
-
- if len_ > 4 {
- offset, err := ida.Allocate(valueBytes)
- log.PanicIf(err)
-
- err = bw.WriteUint32(offset)
- log.PanicIf(err)
- } else {
- fourBytes := make([]byte, 4)
- copy(fourBytes, valueBytes)
-
- err = bw.WriteFourBytes(fourBytes)
- log.PanicIf(err)
- }
- } else {
- if bt.value.IsIb() == false {
- log.Panicf("tag value is not a byte-slice but also not a child IB: %v", bt)
- }
-
- // Write unit-count (one LONG representing one offset).
- err = bw.WriteUint32(1)
- log.PanicIf(err)
-
- if nextIfdOffsetToWrite > 0 {
- var err error
-
- ibe.pushToJournal("encodeTagToBytes", ">", "[%s]->[%s]", ib.IfdIdentity().UnindexedString(), bt.value.Ib().IfdIdentity().UnindexedString())
-
- // Create the block of IFD data and everything it requires.
- childIfdBlock, err = ibe.encodeAndAttachIfd(bt.value.Ib(), nextIfdOffsetToWrite)
- log.PanicIf(err)
-
- ibe.pushToJournal("encodeTagToBytes", "<", "[%s]->[%s]", bt.value.Ib().IfdIdentity().UnindexedString(), ib.IfdIdentity().UnindexedString())
-
- // Use the next-IFD offset for it. The IFD will actually get
- // attached after we return.
- err = bw.WriteUint32(nextIfdOffsetToWrite)
- log.PanicIf(err)
-
- } else {
- // No child-IFDs are to be allocated. Finish the entry with a NULL
- // pointer.
-
- ibe.pushToJournal("encodeTagToBytes", "-", "*Not* descending to child: [%s]", bt.value.Ib().IfdIdentity().UnindexedString())
-
- err = bw.WriteUint32(0)
- log.PanicIf(err)
- }
- }
-
- return childIfdBlock, nil
-}
-
-// encodeIfdToBytes encodes the given IB to a byte-slice. We are given the
-// offset at which this IFD will be written. This method is used called both to
-// pre-determine how big the table is going to be (so that we can calculate the
-// address to allocate data at) as well as to write the final table.
-//
-// It is necessary to fully realize the table in order to predetermine its size
-// because it is not enough to know the size of the table: If there are child
-// IFDs, we will not be able to allocate them without first knowing how much
-// data we need to allocate for the current IFD.
-func (ibe *IfdByteEncoder) encodeIfdToBytes(ib *IfdBuilder, ifdAddressableOffset uint32, nextIfdOffsetToWrite uint32, setNextIb bool) (data []byte, tableSize uint32, dataSize uint32, childIfdSizes []uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ibe.pushToJournal("encodeIfdToBytes", ">", "%s", ib)
-
- tableSize = ibe.TableSize(len(ib.tags))
-
- b := new(bytes.Buffer)
- bw := NewByteWriter(b, ib.byteOrder)
-
- // Write tag count.
- err = bw.WriteUint16(uint16(len(ib.tags)))
- log.PanicIf(err)
-
- ida := newIfdDataAllocator(ifdAddressableOffset)
-
- childIfdBlocks := make([][]byte, 0)
-
- // Write raw bytes for each tag entry. Allocate larger data to be referred
- // to in the follow-up data-block as required. Any "unknown"-byte tags that
- // we can't parse will not be present here (using AddTagsFromExisting(), at
- // least).
- for _, bt := range ib.tags {
- childIfdBlock, err := ibe.encodeTagToBytes(ib, bt, bw, ida, nextIfdOffsetToWrite)
- log.PanicIf(err)
-
- if childIfdBlock != nil {
- // We aren't allowed to have non-nil child IFDs if we're just
- // sizing things up.
- if nextIfdOffsetToWrite == 0 {
- log.Panicf("no IFD offset provided for child-IFDs; no new child-IFDs permitted")
- }
-
- nextIfdOffsetToWrite += uint32(len(childIfdBlock))
- childIfdBlocks = append(childIfdBlocks, childIfdBlock)
- }
- }
-
- dataBytes := ida.Bytes()
- dataSize = uint32(len(dataBytes))
-
- childIfdSizes = make([]uint32, len(childIfdBlocks))
- childIfdsTotalSize := uint32(0)
- for i, childIfdBlock := range childIfdBlocks {
- len_ := uint32(len(childIfdBlock))
- childIfdSizes[i] = len_
- childIfdsTotalSize += len_
- }
-
- // N the link from this IFD to the next IFD that will be written in the
- // next cycle.
- if setNextIb == true {
- // Write address of next IFD in chain. This will be the original
- // allocation offset plus the size of everything we have allocated for
- // this IFD and its child-IFDs.
- //
- // It is critical that this number is stepped properly. We experienced
- // an issue whereby it first looked like we were duplicating the IFD and
- // then that we were duplicating the tags in the wrong IFD, and then
- // finally we determined that the next-IFD offset for the first IFD was
- // accidentally pointing back to the EXIF IFD, so we were visiting it
- // twice when visiting through the tags after decoding. It was an
- // expensive bug to find.
-
- ibe.pushToJournal("encodeIfdToBytes", "-", "Setting 'next' IFD to (0x%08x).", nextIfdOffsetToWrite)
-
- err := bw.WriteUint32(nextIfdOffsetToWrite)
- log.PanicIf(err)
- } else {
- err := bw.WriteUint32(0)
- log.PanicIf(err)
- }
-
- _, err = b.Write(dataBytes)
- log.PanicIf(err)
-
- // Append any child IFD blocks after our table and data blocks. These IFDs
- // were equipped with the appropriate offset information so it's expected
- // that all offsets referred to by these will be correct.
- //
- // Note that child-IFDs are append after the current IFD and before the
- // next IFD, as opposed to the root IFDs, which are chained together but
- // will be interrupted by these child-IFDs (which is expected, per the
- // standard).
-
- for _, childIfdBlock := range childIfdBlocks {
- _, err = b.Write(childIfdBlock)
- log.PanicIf(err)
- }
-
- ibe.pushToJournal("encodeIfdToBytes", "<", "%s", ib)
-
- return b.Bytes(), tableSize, dataSize, childIfdSizes, nil
-}
-
-// encodeAndAttachIfd is a reentrant function that processes the IFD chain.
-func (ibe *IfdByteEncoder) encodeAndAttachIfd(ib *IfdBuilder, ifdAddressableOffset uint32) (data []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ibe.pushToJournal("encodeAndAttachIfd", ">", "%s", ib)
-
- b := new(bytes.Buffer)
-
- i := 0
-
- for thisIb := ib; thisIb != nil; thisIb = thisIb.nextIb {
-
- // Do a dry-run in order to pre-determine its size requirement.
-
- ibe.pushToJournal("encodeAndAttachIfd", ">", "Beginning encoding process: (%d) [%s]", i, thisIb.IfdIdentity().UnindexedString())
-
- ibe.pushToJournal("encodeAndAttachIfd", ">", "Calculating size: (%d) [%s]", i, thisIb.IfdIdentity().UnindexedString())
-
- _, tableSize, allocatedDataSize, _, err := ibe.encodeIfdToBytes(thisIb, ifdAddressableOffset, 0, false)
- log.PanicIf(err)
-
- ibe.pushToJournal("encodeAndAttachIfd", "<", "Finished calculating size: (%d) [%s]", i, thisIb.IfdIdentity().UnindexedString())
-
- ifdAddressableOffset += tableSize
- nextIfdOffsetToWrite := ifdAddressableOffset + allocatedDataSize
-
- ibe.pushToJournal("encodeAndAttachIfd", ">", "Next IFD will be written at offset (0x%08x)", nextIfdOffsetToWrite)
-
- // Write our IFD as well as any child-IFDs (now that we know the offset
- // where new IFDs and their data will be allocated).
-
- setNextIb := thisIb.nextIb != nil
-
- ibe.pushToJournal("encodeAndAttachIfd", ">", "Encoding starting: (%d) [%s] NEXT-IFD-OFFSET-TO-WRITE=(0x%08x)", i, thisIb.IfdIdentity().UnindexedString(), nextIfdOffsetToWrite)
-
- tableAndAllocated, effectiveTableSize, effectiveAllocatedDataSize, childIfdSizes, err :=
- ibe.encodeIfdToBytes(thisIb, ifdAddressableOffset, nextIfdOffsetToWrite, setNextIb)
-
- log.PanicIf(err)
-
- if effectiveTableSize != tableSize {
- log.Panicf("written table size does not match the pre-calculated table size: (%d) != (%d) %s", effectiveTableSize, tableSize, ib)
- } else if effectiveAllocatedDataSize != allocatedDataSize {
- log.Panicf("written allocated-data size does not match the pre-calculated allocated-data size: (%d) != (%d) %s", effectiveAllocatedDataSize, allocatedDataSize, ib)
- }
-
- ibe.pushToJournal("encodeAndAttachIfd", "<", "Encoding done: (%d) [%s]", i, thisIb.IfdIdentity().UnindexedString())
-
- totalChildIfdSize := uint32(0)
- for _, childIfdSize := range childIfdSizes {
- totalChildIfdSize += childIfdSize
- }
-
- if len(tableAndAllocated) != int(tableSize+allocatedDataSize+totalChildIfdSize) {
- log.Panicf("IFD table and data is not a consistent size: (%d) != (%d)", len(tableAndAllocated), tableSize+allocatedDataSize+totalChildIfdSize)
- }
-
- // TODO(dustin): We might want to verify the original tableAndAllocated length, too.
-
- _, err = b.Write(tableAndAllocated)
- log.PanicIf(err)
-
- // Advance past what we've allocated, thus far.
-
- ifdAddressableOffset += allocatedDataSize + totalChildIfdSize
-
- ibe.pushToJournal("encodeAndAttachIfd", "<", "Finishing encoding process: (%d) [%s] [FINAL:] NEXT-IFD-OFFSET-TO-WRITE=(0x%08x)", i, ib.IfdIdentity().UnindexedString(), nextIfdOffsetToWrite)
-
- i++
- }
-
- ibe.pushToJournal("encodeAndAttachIfd", "<", "%s", ib)
-
- return b.Bytes(), nil
-}
-
-// EncodeToExifPayload is the base encoding step that transcribes the entire IB
-// structure to its on-disk layout.
-func (ibe *IfdByteEncoder) EncodeToExifPayload(ib *IfdBuilder) (data []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- data, err = ibe.encodeAndAttachIfd(ib, ExifDefaultFirstIfdOffset)
- log.PanicIf(err)
-
- return data, nil
-}
-
-// EncodeToExif calls EncodeToExifPayload and then packages the result into a
-// complete EXIF block.
-func (ibe *IfdByteEncoder) EncodeToExif(ib *IfdBuilder) (data []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- encodedIfds, err := ibe.EncodeToExifPayload(ib)
- log.PanicIf(err)
-
- // Wrap the IFD in a formal EXIF block.
-
- b := new(bytes.Buffer)
-
- headerBytes, err := BuildExifHeader(ib.byteOrder, ExifDefaultFirstIfdOffset)
- log.PanicIf(err)
-
- _, err = b.Write(headerBytes)
- log.PanicIf(err)
-
- _, err = b.Write(encodedIfds)
- log.PanicIf(err)
-
- return b.Bytes(), nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/ifd_enumerate.go b/vendor/github.com/dsoprea/go-exif/v2/ifd_enumerate.go
deleted file mode 100644
index 33a5f84b3..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/ifd_enumerate.go
+++ /dev/null
@@ -1,1521 +0,0 @@
-package exif
-
-import (
- "bytes"
- "errors"
- "fmt"
- "io"
- "strconv"
- "strings"
- "time"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
- "github.com/dsoprea/go-exif/v2/undefined"
-)
-
-var (
- ifdEnumerateLogger = log.NewLogger("exif.ifd_enumerate")
-)
-
-var (
- // ErrNoThumbnail means that no thumbnail was found.
- ErrNoThumbnail = errors.New("no thumbnail")
-
- // ErrNoGpsTags means that no GPS info was found.
- ErrNoGpsTags = errors.New("no gps tags")
-
- // ErrTagTypeNotValid means that the tag-type is not valid.
- ErrTagTypeNotValid = errors.New("tag type invalid")
-
- // ErrOffsetInvalid means that the file offset is not valid.
- ErrOffsetInvalid = errors.New("file offset invalid")
-)
-
-var (
- // ValidGpsVersions is the list of recognized EXIF GPS versions/signatures.
- ValidGpsVersions = [][4]byte{
- // 2.0.0.0 appears to have a very similar format to 2.2.0.0, so enabling
- // it under that assumption.
- //
- // IFD-PATH=[IFD] ID=(0x8825) NAME=[GPSTag] COUNT=(1) TYPE=[LONG] VALUE=[114]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0000) NAME=[GPSVersionID] COUNT=(4) TYPE=[BYTE] VALUE=[02 00 00 00]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0001) NAME=[GPSLatitudeRef] COUNT=(2) TYPE=[ASCII] VALUE=[S]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0002) NAME=[GPSLatitude] COUNT=(3) TYPE=[RATIONAL] VALUE=[38/1...]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0003) NAME=[GPSLongitudeRef] COUNT=(2) TYPE=[ASCII] VALUE=[E]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0004) NAME=[GPSLongitude] COUNT=(3) TYPE=[RATIONAL] VALUE=[144/1...]
- // IFD-PATH=[IFD/GPSInfo] ID=(0x0012) NAME=[GPSMapDatum] COUNT=(7) TYPE=[ASCII] VALUE=[WGS-84]
- //
- {2, 0, 0, 0},
-
- {2, 2, 0, 0},
-
- // Suddenly appeared at the default in 2.31: https://home.jeita.or.jp/tsc/std-pdf/CP-3451D.pdf
- //
- // Note that the presence of 2.3.0.0 doesn't seem to guarantee
- // coordinates. In some cases, we seen just the following:
- //
- // GPS Tag Version |2.3.0.0
- // GPS Receiver Status |V
- // Geodetic Survey Data|WGS-84
- // GPS Differential Cor|0
- //
- {2, 3, 0, 0},
- }
-)
-
-// byteParser 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 byteParser struct {
- byteOrder binary.ByteOrder
- addressableData []byte
- ifdOffset uint32
- currentOffset uint32
-}
-
-func newByteParser(addressableData []byte, byteOrder binary.ByteOrder, ifdOffset uint32) (bp *byteParser, err error) {
- if ifdOffset >= uint32(len(addressableData)) {
- return nil, ErrOffsetInvalid
- }
-
- // TODO(dustin): Add test
-
- bp = &byteParser{
- addressableData: addressableData,
- byteOrder: byteOrder,
- currentOffset: ifdOffset,
- }
-
- return bp, nil
-}
-
-// getUint16 reads a uint16 and advances both our current and our current
-// accumulator (which allows us to know how far to seek to the beginning of the
-// next IFD when it's time to jump).
-func (bp *byteParser) getUint16() (value uint16, raw []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- needBytes := uint32(2)
-
- if bp.currentOffset+needBytes > uint32(len(bp.addressableData)) {
- return 0, nil, io.EOF
- }
-
- raw = bp.addressableData[bp.currentOffset : bp.currentOffset+needBytes]
- value = bp.byteOrder.Uint16(raw)
-
- bp.currentOffset += uint32(needBytes)
-
- return value, raw, nil
-}
-
-// getUint32 reads a uint32 and advances both our current and our current
-// accumulator (which allows us to know how far to seek to the beginning of the
-// next IFD when it's time to jump).
-func (bp *byteParser) getUint32() (value uint32, raw []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- needBytes := uint32(4)
-
- if bp.currentOffset+needBytes > uint32(len(bp.addressableData)) {
- return 0, nil, io.EOF
- }
-
- raw = bp.addressableData[bp.currentOffset : bp.currentOffset+needBytes]
- value = bp.byteOrder.Uint32(raw)
-
- bp.currentOffset += uint32(needBytes)
-
- return value, raw, nil
-}
-
-// CurrentOffset returns the starting offset but the number of bytes that we
-// have parsed. This is arithmetic-based tracking, not a seek(0) operation.
-func (bp *byteParser) CurrentOffset() uint32 {
- return bp.currentOffset
-}
-
-// IfdEnumerate is the main enumeration type. It knows how to parse the IFD
-// containers in the EXIF blob.
-type IfdEnumerate struct {
- exifData []byte
- byteOrder binary.ByteOrder
- tagIndex *TagIndex
- ifdMapping *exifcommon.IfdMapping
- furthestOffset uint32
-}
-
-// NewIfdEnumerate returns a new instance of IfdEnumerate.
-func NewIfdEnumerate(ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, exifData []byte, byteOrder binary.ByteOrder) *IfdEnumerate {
- return &IfdEnumerate{
- exifData: exifData,
- byteOrder: byteOrder,
- ifdMapping: ifdMapping,
- tagIndex: tagIndex,
- }
-}
-
-func (ie *IfdEnumerate) getByteParser(ifdOffset uint32) (bp *byteParser, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- bp, err =
- newByteParser(
- ie.exifData[ExifAddressableAreaStart:],
- ie.byteOrder,
- ifdOffset)
-
- if err != nil {
- if err == ErrOffsetInvalid {
- return nil, err
- }
-
- log.Panic(err)
- }
-
- return bp, nil
-}
-
-func (ie *IfdEnumerate) parseTag(ii *exifcommon.IfdIdentity, tagPosition int, bp *byteParser) (ite *IfdTagEntry, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- tagId, _, err := bp.getUint16()
- log.PanicIf(err)
-
- tagTypeRaw, _, err := bp.getUint16()
- log.PanicIf(err)
-
- tagType := exifcommon.TagTypePrimitive(tagTypeRaw)
-
- unitCount, _, err := bp.getUint32()
- log.PanicIf(err)
-
- valueOffset, rawValueOffset, err := bp.getUint32()
- log.PanicIf(err)
-
- if tagType.IsValid() == false {
- ite = &IfdTagEntry{
- tagId: tagId,
- tagType: tagType,
- }
-
- log.Panic(ErrTagTypeNotValid)
- }
-
- ite = newIfdTagEntry(
- ii,
- tagId,
- tagPosition,
- tagType,
- unitCount,
- valueOffset,
- rawValueOffset,
- ie.exifData[ExifAddressableAreaStart:],
- ie.byteOrder)
-
- ifdPath := ii.UnindexedString()
-
- // If it's an IFD but not a standard one, it'll just be seen as a LONG
- // (the standard IFD tag type), later, unless we skip it because it's
- // [likely] not even in the standard list of known tags.
- mi, err := ie.ifdMapping.GetChild(ifdPath, tagId)
- if err == nil {
- currentIfdTag := ii.IfdTag()
-
- childIt := exifcommon.NewIfdTag(&currentIfdTag, tagId, mi.Name)
- iiChild := ii.NewChild(childIt, 0)
- ite.SetChildIfd(iiChild)
-
- // We also need to set `tag.ChildFqIfdPath` but can't do it here
- // because we don't have the IFD index.
- } else if log.Is(err, exifcommon.ErrChildIfdNotMapped) == false {
- log.Panic(err)
- }
-
- return ite, nil
-}
-
-// TagVisitorFn is called for each tag when enumerating through the EXIF.
-type TagVisitorFn func(fqIfdPath string, ifdIndex int, ite *IfdTagEntry) (err error)
-
-// postparseTag do some tag-level processing here following the parse of each.
-func (ie *IfdEnumerate) postparseTag(ite *IfdTagEntry, med *MiscellaneousExifData) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- ii := ite.IfdIdentity()
-
- tagId := ite.TagId()
- tagType := ite.TagType()
-
- it, err := ie.tagIndex.Get(ii, tagId)
- if err == nil {
- ite.setTagName(it.Name)
- } else {
- if err != ErrTagNotFound {
- log.Panic(err)
- }
-
- // This is an unknown tag.
-
- originalBt := exifcommon.BasicTag{
- FqIfdPath: ii.String(),
- IfdPath: ii.UnindexedString(),
- TagId: tagId,
- }
-
- if med != nil {
- med.unknownTags[originalBt] = exifcommon.BasicTag{}
- }
-
- utilityLogger.Debugf(nil,
- "Tag (0x%04x) is not valid for IFD [%s]. Attempting secondary "+
- "lookup.", tagId, ii.String())
-
- // This will overwrite the existing `it` and `err`. Since `FindFirst()`
- // might generate different Errors than `Get()`, the log message above
- // is import to try and mitigate confusion in that case.
- it, err = ie.tagIndex.FindFirst(tagId, tagType, nil)
- if err != nil {
- if err != ErrTagNotFound {
- log.Panic(err)
- }
-
- // This is supposed to be a convenience function and if we were
- // to keep the name empty or set it to some placeholder, it
- // might be mismanaged by the package that is calling us. If
- // they want to specifically manage these types of tags, they
- // can use more advanced functionality to specifically -handle
- // unknown tags.
- utilityLogger.Warningf(nil,
- "Tag with ID (0x%04x) in IFD [%s] is not recognized and "+
- "will be ignored.", tagId, ii.String())
-
- return ErrTagNotFound
- }
-
- ite.setTagName(it.Name)
-
- utilityLogger.Warningf(nil,
- "Tag with ID (0x%04x) is not valid for IFD [%s], but it *is* "+
- "valid as tag [%s] under IFD [%s] and has the same type "+
- "[%s], so we will use that. This EXIF blob was probably "+
- "written by a buggy implementation.",
- tagId, ii.UnindexedString(), it.Name, it.IfdPath,
- tagType)
-
- if med != nil {
- med.unknownTags[originalBt] = exifcommon.BasicTag{
- IfdPath: it.IfdPath,
- TagId: tagId,
- }
- }
- }
-
- // This is a known tag (from the standard, unless the user did
- // something different).
-
- // Skip any tags that have a type that doesn't match the type in the
- // index (which is loaded with the standard and accept tag
- // information unless configured otherwise).
- //
- // We've run into multiple instances of the same tag, where a) no
- // tag should ever be repeated, and b) all but one had an incorrect
- // type and caused parsing/conversion woes. So, this is a quick fix
- // for those scenarios.
- if it.DoesSupportType(tagType) == false {
- ifdEnumerateLogger.Warningf(nil,
- "Skipping tag [%s] (0x%04x) [%s] with an unexpected type: %v ∉ %v",
- ii.UnindexedString(), tagId, it.Name,
- tagType, it.SupportedTypes)
-
- return ErrTagNotFound
- }
-
- return nil
-}
-
-// parseIfd decodes the IFD block that we're currently sitting on the first
-// byte of.
-func (ie *IfdEnumerate) parseIfd(ii *exifcommon.IfdIdentity, bp *byteParser, visitor TagVisitorFn, doDescend bool, med *MiscellaneousExifData) (nextIfdOffset uint32, entries []*IfdTagEntry, thumbnailData []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- tagCount, _, err := bp.getUint16()
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "IFD [%s] tag-count: (%d)", ii.String(), tagCount)
-
- entries = make([]*IfdTagEntry, 0)
-
- var enumeratorThumbnailOffset *IfdTagEntry
- var enumeratorThumbnailSize *IfdTagEntry
-
- for i := 0; i < int(tagCount); i++ {
- ite, err := ie.parseTag(ii, i, bp)
- if err != nil {
- if log.Is(err, ErrTagTypeNotValid) == true {
- // Technically, we have the type on-file in the tags-index, but
- // if the type stored alongside the data disagrees with it,
- // which it apparently does, all bets are off.
- ifdEnumerateLogger.Warningf(nil, "Tag (0x%04x) in IFD [%s] at position (%d) has invalid type (%d) and will be skipped.", ite.tagId, ii, i, ite.tagType)
- continue
- }
-
- log.Panic(err)
- }
-
- err = ie.postparseTag(ite, med)
- if err == nil {
- if err == ErrTagNotFound {
- continue
- }
-
- log.PanicIf(err)
- }
-
- tagId := ite.TagId()
-
- if visitor != nil {
- err := visitor(ii.String(), ii.Index(), ite)
- log.PanicIf(err)
- }
-
- if ite.IsThumbnailOffset() == true {
- ifdEnumerateLogger.Debugf(nil, "Skipping the thumbnail offset tag (0x%04x). Use accessors to get it or set it.", tagId)
-
- enumeratorThumbnailOffset = ite
- entries = append(entries, ite)
-
- continue
- } else if ite.IsThumbnailSize() == true {
- ifdEnumerateLogger.Debugf(nil, "Skipping the thumbnail size tag (0x%04x). Use accessors to get it or set it.", tagId)
-
- enumeratorThumbnailSize = ite
- entries = append(entries, ite)
-
- continue
- }
-
- if ite.TagType() != exifcommon.TypeUndefined {
- // If this tag's value is an offset, bump our max-offset value to
- // what that offset is plus however large that value is.
-
- vc := ite.getValueContext()
-
- farOffset, err := vc.GetFarOffset()
- if err == nil {
- candidateOffset := farOffset + uint32(vc.SizeInBytes())
- if candidateOffset > ie.furthestOffset {
- ie.furthestOffset = candidateOffset
- }
- } else if err != exifcommon.ErrNotFarValue {
- log.PanicIf(err)
- }
- }
-
- // If it's an IFD but not a standard one, it'll just be seen as a LONG
- // (the standard IFD tag type), later, unless we skip it because it's
- // [likely] not even in the standard list of known tags.
- if ite.ChildIfdPath() != "" {
- if doDescend == true {
- ifdEnumerateLogger.Debugf(nil, "Descending from IFD [%s] to IFD [%s].", ii, ite.ChildIfdPath())
-
- currentIfdTag := ii.IfdTag()
-
- childIfdTag :=
- exifcommon.NewIfdTag(
- &currentIfdTag,
- ite.TagId(),
- ite.ChildIfdName())
-
- iiChild := ii.NewChild(childIfdTag, 0)
-
- err := ie.scan(iiChild, ite.getValueOffset(), visitor, med)
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Ascending from IFD [%s] to IFD [%s].", ite.ChildIfdPath(), ii)
- }
- }
-
- entries = append(entries, ite)
- }
-
- if enumeratorThumbnailOffset != nil && enumeratorThumbnailSize != nil {
- thumbnailData, err = ie.parseThumbnail(enumeratorThumbnailOffset, enumeratorThumbnailSize)
- log.PanicIf(err)
-
- // In this case, the value is always an offset.
- offset := enumeratorThumbnailOffset.getValueOffset()
-
- // This this case, the value is always a length.
- length := enumeratorThumbnailSize.getValueOffset()
-
- ifdEnumerateLogger.Debugf(nil, "Found thumbnail in IFD [%s]. Its offset is (%d) and is (%d) bytes.", ii, offset, length)
-
- furthestOffset := offset + length
-
- if furthestOffset > ie.furthestOffset {
- ie.furthestOffset = furthestOffset
- }
- }
-
- nextIfdOffset, _, err = bp.getUint32()
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Next IFD at offset: (%08x)", nextIfdOffset)
-
- return nextIfdOffset, entries, thumbnailData, nil
-}
-
-func (ie *IfdEnumerate) parseThumbnail(offsetIte, lengthIte *IfdTagEntry) (thumbnailData []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- vRaw, err := lengthIte.Value()
- log.PanicIf(err)
-
- vList := vRaw.([]uint32)
- if len(vList) != 1 {
- log.Panicf("not exactly one long: (%d)", len(vList))
- }
-
- length := vList[0]
-
- // The tag is official a LONG type, but it's actually an offset to a blob of bytes.
- offsetIte.updateTagType(exifcommon.TypeByte)
- offsetIte.updateUnitCount(length)
-
- thumbnailData, err = offsetIte.GetRawBytes()
- log.PanicIf(err)
-
- return thumbnailData, nil
-}
-
-// scan parses and enumerates the different IFD blocks and invokes a visitor
-// callback for each tag. No information is kept or returned.
-func (ie *IfdEnumerate) scan(iiGeneral *exifcommon.IfdIdentity, ifdOffset uint32, visitor TagVisitorFn, med *MiscellaneousExifData) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- for ifdIndex := 0; ; ifdIndex++ {
- iiSibling := iiGeneral.NewSibling(ifdIndex)
-
- ifdEnumerateLogger.Debugf(nil, "Parsing IFD [%s] at offset (0x%04x) (scan).", iiSibling.String(), ifdOffset)
-
- bp, err := ie.getByteParser(ifdOffset)
- if err != nil {
- if err == ErrOffsetInvalid {
- ifdEnumerateLogger.Errorf(nil, nil, "IFD [%s] at offset (0x%04x) is unreachable. Terminating scan.", iiSibling.String(), ifdOffset)
- break
- }
-
- log.Panic(err)
- }
-
- nextIfdOffset, _, _, err := ie.parseIfd(iiSibling, bp, visitor, true, med)
- log.PanicIf(err)
-
- currentOffset := bp.CurrentOffset()
- if currentOffset > ie.furthestOffset {
- ie.furthestOffset = currentOffset
- }
-
- if nextIfdOffset == 0 {
- break
- }
-
- ifdOffset = nextIfdOffset
- }
-
- return nil
-}
-
-// MiscellaneousExifData is reports additional data collected during the parse.
-type MiscellaneousExifData struct {
- // UnknownTags contains all tags that were invalid for their containing
- // IFDs. The values represent alternative IFDs that were correctly matched
- // to those tags and used instead.
- unknownTags map[exifcommon.BasicTag]exifcommon.BasicTag
-}
-
-// UnknownTags returns the unknown tags encountered during the scan.
-func (med *MiscellaneousExifData) UnknownTags() map[exifcommon.BasicTag]exifcommon.BasicTag {
- return med.unknownTags
-}
-
-// Scan enumerates the different EXIF blocks (called IFDs). `rootIfdName` will
-// be "IFD" in the TIFF standard.
-func (ie *IfdEnumerate) Scan(iiRoot *exifcommon.IfdIdentity, ifdOffset uint32, visitor TagVisitorFn) (med *MiscellaneousExifData, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- med = &MiscellaneousExifData{
- unknownTags: make(map[exifcommon.BasicTag]exifcommon.BasicTag),
- }
-
- err = ie.scan(iiRoot, ifdOffset, visitor, med)
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Scan: It looks like the furthest offset that contained EXIF data in the EXIF blob was (%d) (Scan).", ie.FurthestOffset())
-
- return med, nil
-}
-
-// Ifd represents a single, parsed IFD.
-type Ifd struct {
-
- // TODO(dustin): Add NextIfd().
-
- ifdIdentity *exifcommon.IfdIdentity
-
- ByteOrder binary.ByteOrder
-
- Id int
-
- ParentIfd *Ifd
-
- // ParentTagIndex is our tag position in the parent IFD, if we had a parent
- // (if `ParentIfd` is not nil and we weren't an IFD referenced as a sibling
- // instead of as a child).
- ParentTagIndex int
-
- Offset uint32
-
- Entries []*IfdTagEntry
- EntriesByTagId map[uint16][]*IfdTagEntry
-
- Children []*Ifd
-
- ChildIfdIndex map[string]*Ifd
-
- NextIfdOffset uint32
- NextIfd *Ifd
-
- thumbnailData []byte
-
- ifdMapping *exifcommon.IfdMapping
- tagIndex *TagIndex
-}
-
-// IfdIdentity returns IFD identity that this struct represents.
-func (ifd *Ifd) IfdIdentity() *exifcommon.IfdIdentity {
- return ifd.ifdIdentity
-}
-
-// ChildWithIfdPath returns an `Ifd` struct for the given child of the current
-// IFD.
-func (ifd *Ifd) ChildWithIfdPath(iiChild *exifcommon.IfdIdentity) (childIfd *Ifd, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): This is a bridge while we're introducing the IFD type-system. We should be able to use the (IfdIdentity).Equals() method for this.
- ifdPath := iiChild.UnindexedString()
-
- for _, childIfd := range ifd.Children {
- if childIfd.ifdIdentity.UnindexedString() == ifdPath {
- return childIfd, nil
- }
- }
-
- log.Panic(ErrTagNotFound)
- return nil, nil
-}
-
-// FindTagWithId returns a list of tags (usually just zero or one) that match
-// the given tag ID. This is efficient.
-func (ifd *Ifd) FindTagWithId(tagId uint16) (results []*IfdTagEntry, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- results, found := ifd.EntriesByTagId[tagId]
- if found != true {
- log.Panic(ErrTagNotFound)
- }
-
- return results, nil
-}
-
-// FindTagWithName returns a list of tags (usually just zero or one) that match
-// the given tag name. This is not efficient (though the labor is trivial).
-func (ifd *Ifd) FindTagWithName(tagName string) (results []*IfdTagEntry, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- it, err := ifd.tagIndex.GetWithName(ifd.ifdIdentity, tagName)
- if log.Is(err, ErrTagNotFound) == true {
- log.Panic(ErrTagNotKnown)
- } else if err != nil {
- log.Panic(err)
- }
-
- results = make([]*IfdTagEntry, 0)
- for _, ite := range ifd.Entries {
- if ite.TagId() == it.Id {
- results = append(results, ite)
- }
- }
-
- if len(results) == 0 {
- log.Panic(ErrTagNotFound)
- }
-
- return results, nil
-}
-
-// String returns a description string.
-func (ifd *Ifd) String() string {
- parentOffset := uint32(0)
- if ifd.ParentIfd != nil {
- parentOffset = ifd.ParentIfd.Offset
- }
-
- return fmt.Sprintf("Ifd<ID=(%d) IFD-PATH=[%s] INDEX=(%d) COUNT=(%d) OFF=(0x%04x) CHILDREN=(%d) PARENT=(0x%04x) NEXT-IFD=(0x%04x)>", ifd.Id, ifd.ifdIdentity.UnindexedString(), ifd.ifdIdentity.Index(), len(ifd.Entries), ifd.Offset, len(ifd.Children), parentOffset, ifd.NextIfdOffset)
-}
-
-// Thumbnail returns the raw thumbnail bytes. This is typically directly
-// readable by any standard image viewer.
-func (ifd *Ifd) Thumbnail() (data []byte, err error) {
-
- if ifd.thumbnailData == nil {
- return nil, ErrNoThumbnail
- }
-
- return ifd.thumbnailData, nil
-}
-
-// dumpTags recursively builds a list of tags from an IFD.
-func (ifd *Ifd) dumpTags(tags []*IfdTagEntry) []*IfdTagEntry {
- if tags == nil {
- tags = make([]*IfdTagEntry, 0)
- }
-
- // Now, print the tags while also descending to child-IFDS as we encounter them.
-
- ifdsFoundCount := 0
-
- for _, ite := range ifd.Entries {
- tags = append(tags, ite)
-
- childIfdPath := ite.ChildIfdPath()
- if childIfdPath != "" {
- ifdsFoundCount++
-
- childIfd, found := ifd.ChildIfdIndex[childIfdPath]
- if found != true {
- log.Panicf("alien child IFD referenced by a tag: [%s]", childIfdPath)
- }
-
- tags = childIfd.dumpTags(tags)
- }
- }
-
- if len(ifd.Children) != ifdsFoundCount {
- log.Panicf("have one or more dangling child IFDs: (%d) != (%d)", len(ifd.Children), ifdsFoundCount)
- }
-
- if ifd.NextIfd != nil {
- tags = ifd.NextIfd.dumpTags(tags)
- }
-
- return tags
-}
-
-// DumpTags prints the IFD hierarchy.
-func (ifd *Ifd) DumpTags() []*IfdTagEntry {
- return ifd.dumpTags(nil)
-}
-
-func (ifd *Ifd) printTagTree(populateValues bool, index, level int, nextLink bool) {
- indent := strings.Repeat(" ", level*2)
-
- prefix := " "
- if nextLink {
- prefix = ">"
- }
-
- fmt.Printf("%s%sIFD: %s\n", indent, prefix, ifd)
-
- // Now, print the tags while also descending to child-IFDS as we encounter them.
-
- ifdsFoundCount := 0
-
- for _, ite := range ifd.Entries {
- if ite.ChildIfdPath() != "" {
- fmt.Printf("%s - TAG: %s\n", indent, ite)
- } else {
- // This will just add noise to the output (byte-tags are fully
- // dumped).
- if ite.IsThumbnailOffset() == true || ite.IsThumbnailSize() == true {
- continue
- }
-
- it, err := ifd.tagIndex.Get(ifd.ifdIdentity, ite.TagId())
-
- tagName := ""
- if err == nil {
- tagName = it.Name
- }
-
- var valuePhrase string
- if populateValues == true {
- var err error
-
- valuePhrase, err = ite.Format()
- if err != nil {
- if log.Is(err, exifcommon.ErrUnhandledUndefinedTypedTag) == true {
- ifdEnumerateLogger.Warningf(nil, "Skipping non-standard undefined tag: [%s] (%04x)", ifd.ifdIdentity.UnindexedString(), ite.TagId())
- continue
- } else if err == exifundefined.ErrUnparseableValue {
- ifdEnumerateLogger.Warningf(nil, "Skipping unparseable undefined tag: [%s] (%04x) [%s]", ifd.ifdIdentity.UnindexedString(), ite.TagId(), it.Name)
- continue
- }
-
- log.Panic(err)
- }
- } else {
- valuePhrase = "!UNRESOLVED"
- }
-
- fmt.Printf("%s - TAG: %s NAME=[%s] VALUE=[%v]\n", indent, ite, tagName, valuePhrase)
- }
-
- childIfdPath := ite.ChildIfdPath()
- if childIfdPath != "" {
- ifdsFoundCount++
-
- childIfd, found := ifd.ChildIfdIndex[childIfdPath]
- if found != true {
- log.Panicf("alien child IFD referenced by a tag: [%s]", childIfdPath)
- }
-
- childIfd.printTagTree(populateValues, 0, level+1, false)
- }
- }
-
- if len(ifd.Children) != ifdsFoundCount {
- log.Panicf("have one or more dangling child IFDs: (%d) != (%d)", len(ifd.Children), ifdsFoundCount)
- }
-
- if ifd.NextIfd != nil {
- ifd.NextIfd.printTagTree(populateValues, index+1, level, true)
- }
-}
-
-// PrintTagTree prints the IFD hierarchy.
-func (ifd *Ifd) PrintTagTree(populateValues bool) {
- ifd.printTagTree(populateValues, 0, 0, false)
-}
-
-func (ifd *Ifd) printIfdTree(level int, nextLink bool) {
- indent := strings.Repeat(" ", level*2)
-
- prefix := " "
- if nextLink {
- prefix = ">"
- }
-
- fmt.Printf("%s%s%s\n", indent, prefix, ifd)
-
- // Now, print the tags while also descending to child-IFDS as we encounter them.
-
- ifdsFoundCount := 0
-
- for _, ite := range ifd.Entries {
- childIfdPath := ite.ChildIfdPath()
- if childIfdPath != "" {
- ifdsFoundCount++
-
- childIfd, found := ifd.ChildIfdIndex[childIfdPath]
- if found != true {
- log.Panicf("alien child IFD referenced by a tag: [%s]", childIfdPath)
- }
-
- childIfd.printIfdTree(level+1, false)
- }
- }
-
- if len(ifd.Children) != ifdsFoundCount {
- log.Panicf("have one or more dangling child IFDs: (%d) != (%d)", len(ifd.Children), ifdsFoundCount)
- }
-
- if ifd.NextIfd != nil {
- ifd.NextIfd.printIfdTree(level, true)
- }
-}
-
-// PrintIfdTree prints the IFD hierarchy.
-func (ifd *Ifd) PrintIfdTree() {
- ifd.printIfdTree(0, false)
-}
-
-func (ifd *Ifd) dumpTree(tagsDump []string, level int) []string {
- if tagsDump == nil {
- tagsDump = make([]string, 0)
- }
-
- indent := strings.Repeat(" ", level*2)
-
- var ifdPhrase string
- if ifd.ParentIfd != nil {
- ifdPhrase = fmt.Sprintf("[%s]->[%s]:(%d)", ifd.ParentIfd.ifdIdentity.UnindexedString(), ifd.ifdIdentity.UnindexedString(), ifd.ifdIdentity.Index())
- } else {
- ifdPhrase = fmt.Sprintf("[ROOT]->[%s]:(%d)", ifd.ifdIdentity.UnindexedString(), ifd.ifdIdentity.Index())
- }
-
- startBlurb := fmt.Sprintf("%s> IFD %s TOP", indent, ifdPhrase)
- tagsDump = append(tagsDump, startBlurb)
-
- ifdsFoundCount := 0
- for _, ite := range ifd.Entries {
- tagsDump = append(tagsDump, fmt.Sprintf("%s - (0x%04x)", indent, ite.TagId()))
-
- childIfdPath := ite.ChildIfdPath()
- if childIfdPath != "" {
- ifdsFoundCount++
-
- childIfd, found := ifd.ChildIfdIndex[childIfdPath]
- if found != true {
- log.Panicf("alien child IFD referenced by a tag: [%s]", childIfdPath)
- }
-
- tagsDump = childIfd.dumpTree(tagsDump, level+1)
- }
- }
-
- if len(ifd.Children) != ifdsFoundCount {
- log.Panicf("have one or more dangling child IFDs: (%d) != (%d)", len(ifd.Children), ifdsFoundCount)
- }
-
- finishBlurb := fmt.Sprintf("%s< IFD %s BOTTOM", indent, ifdPhrase)
- tagsDump = append(tagsDump, finishBlurb)
-
- if ifd.NextIfd != nil {
- siblingBlurb := fmt.Sprintf("%s* LINKING TO SIBLING IFD [%s]:(%d)", indent, ifd.NextIfd.ifdIdentity.UnindexedString(), ifd.NextIfd.ifdIdentity.Index())
- tagsDump = append(tagsDump, siblingBlurb)
-
- tagsDump = ifd.NextIfd.dumpTree(tagsDump, level)
- }
-
- return tagsDump
-}
-
-// DumpTree returns a list of strings describing the IFD hierarchy.
-func (ifd *Ifd) DumpTree() []string {
- return ifd.dumpTree(nil, 0)
-}
-
-// GpsInfo parses and consolidates the GPS info. This can only be called on the
-// GPS IFD.
-func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- gi = new(GpsInfo)
-
- if ifd.ifdIdentity.UnindexedString() != exifcommon.IfdGpsInfoStandardIfdIdentity.UnindexedString() {
- log.Panicf("GPS can only be read on GPS IFD: [%s] != [%s]", ifd.ifdIdentity.UnindexedString(), exifcommon.IfdGpsInfoStandardIfdIdentity.UnindexedString())
- }
-
- if tags, found := ifd.EntriesByTagId[TagGpsVersionId]; found == false {
- // We've seen this. We'll just have to default to assuming we're in a
- // 2.2.0.0 format.
- ifdEnumerateLogger.Warningf(nil, "No GPS version tag (0x%04x) found.", TagGpsVersionId)
- } else {
- versionBytes, err := tags[0].GetRawBytes()
- log.PanicIf(err)
-
- hit := false
- for _, acceptedGpsVersion := range ValidGpsVersions {
- if bytes.Compare(versionBytes, acceptedGpsVersion[:]) == 0 {
- hit = true
- break
- }
- }
-
- if hit != true {
- ifdEnumerateLogger.Warningf(nil, "GPS version not supported: %v", versionBytes)
- log.Panic(ErrNoGpsTags)
- }
- }
-
- tags, found := ifd.EntriesByTagId[TagLatitudeId]
- if found == false {
- ifdEnumerateLogger.Warningf(nil, "latitude not found")
- log.Panic(ErrNoGpsTags)
- }
-
- latitudeValue, err := tags[0].Value()
- log.PanicIf(err)
-
- // Look for whether North or South.
- tags, found = ifd.EntriesByTagId[TagLatitudeRefId]
- if found == false {
- ifdEnumerateLogger.Warningf(nil, "latitude-ref not found")
- log.Panic(ErrNoGpsTags)
- }
-
- latitudeRefValue, err := tags[0].Value()
- log.PanicIf(err)
-
- tags, found = ifd.EntriesByTagId[TagLongitudeId]
- if found == false {
- ifdEnumerateLogger.Warningf(nil, "longitude not found")
- log.Panic(ErrNoGpsTags)
- }
-
- longitudeValue, err := tags[0].Value()
- log.PanicIf(err)
-
- // Look for whether West or East.
- tags, found = ifd.EntriesByTagId[TagLongitudeRefId]
- if found == false {
- ifdEnumerateLogger.Warningf(nil, "longitude-ref not found")
- log.Panic(ErrNoGpsTags)
- }
-
- longitudeRefValue, err := tags[0].Value()
- log.PanicIf(err)
-
- // Parse location.
-
- latitudeRaw := latitudeValue.([]exifcommon.Rational)
-
- gi.Latitude, err = NewGpsDegreesFromRationals(latitudeRefValue.(string), latitudeRaw)
- log.PanicIf(err)
-
- longitudeRaw := longitudeValue.([]exifcommon.Rational)
-
- gi.Longitude, err = NewGpsDegreesFromRationals(longitudeRefValue.(string), longitudeRaw)
- log.PanicIf(err)
-
- // Parse altitude.
-
- altitudeTags, foundAltitude := ifd.EntriesByTagId[TagAltitudeId]
- altitudeRefTags, foundAltitudeRef := ifd.EntriesByTagId[TagAltitudeRefId]
-
- if foundAltitude == true && foundAltitudeRef == true {
- altitudePhrase, err := altitudeTags[0].Format()
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Altitude is [%s].", altitudePhrase)
-
- altitudeValue, err := altitudeTags[0].Value()
- log.PanicIf(err)
-
- altitudeRefPhrase, err := altitudeRefTags[0].Format()
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Altitude-reference is [%s].", altitudeRefPhrase)
-
- altitudeRefValue, err := altitudeRefTags[0].Value()
- log.PanicIf(err)
-
- altitudeRaw := altitudeValue.([]exifcommon.Rational)
- if altitudeRaw[0].Denominator > 0 {
- altitude := int(altitudeRaw[0].Numerator / altitudeRaw[0].Denominator)
-
- if altitudeRefValue.([]byte)[0] == 1 {
- altitude *= -1
- }
-
- gi.Altitude = altitude
- }
- }
-
- // Parse timestamp from separate date and time tags.
-
- timestampTags, foundTimestamp := ifd.EntriesByTagId[TagTimestampId]
- datestampTags, foundDatestamp := ifd.EntriesByTagId[TagDatestampId]
-
- if foundTimestamp == true && foundDatestamp == true {
- datestampValue, err := datestampTags[0].Value()
- log.PanicIf(err)
-
- datePhrase := datestampValue.(string)
- ifdEnumerateLogger.Debugf(nil, "Date tag value is [%s].", datePhrase)
-
- // Normalize the separators.
- datePhrase = strings.ReplaceAll(datePhrase, "-", ":")
-
- dateParts := strings.Split(datePhrase, ":")
-
- year, err1 := strconv.ParseUint(dateParts[0], 10, 16)
- month, err2 := strconv.ParseUint(dateParts[1], 10, 8)
- day, err3 := strconv.ParseUint(dateParts[2], 10, 8)
-
- if err1 == nil && err2 == nil && err3 == nil {
- timestampValue, err := timestampTags[0].Value()
- log.PanicIf(err)
-
- timePhrase, err := timestampTags[0].Format()
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Time tag value is [%s].", timePhrase)
-
- timestampRaw := timestampValue.([]exifcommon.Rational)
-
- hour := int(timestampRaw[0].Numerator / timestampRaw[0].Denominator)
- minute := int(timestampRaw[1].Numerator / timestampRaw[1].Denominator)
- second := int(timestampRaw[2].Numerator / timestampRaw[2].Denominator)
-
- gi.Timestamp = time.Date(int(year), time.Month(month), int(day), hour, minute, second, 0, time.UTC)
- }
- }
-
- return gi, nil
-}
-
-// ParsedTagVisitor is a callback used if wanting to visit through all tags and
-// child IFDs from the current IFD and going down.
-type ParsedTagVisitor func(*Ifd, *IfdTagEntry) error
-
-// EnumerateTagsRecursively calls the given visitor function for every tag and
-// IFD in the current IFD, recursively.
-func (ifd *Ifd) EnumerateTagsRecursively(visitor ParsedTagVisitor) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- for ptr := ifd; ptr != nil; ptr = ptr.NextIfd {
- for _, ite := range ifd.Entries {
- childIfdPath := ite.ChildIfdPath()
- if childIfdPath != "" {
- childIfd := ifd.ChildIfdIndex[childIfdPath]
-
- err := childIfd.EnumerateTagsRecursively(visitor)
- log.PanicIf(err)
- } else {
- err := visitor(ifd, ite)
- log.PanicIf(err)
- }
- }
- }
-
- return nil
-}
-
-// QueuedIfd is one IFD that has been identified but yet to be processed.
-type QueuedIfd struct {
- IfdIdentity *exifcommon.IfdIdentity
-
- Offset uint32
- Parent *Ifd
-
- // ParentTagIndex is our tag position in the parent IFD, if we had a parent
- // (if `ParentIfd` is not nil and we weren't an IFD referenced as a sibling
- // instead of as a child).
- ParentTagIndex int
-}
-
-// IfdIndex collects a bunch of IFD and tag information stored in several
-// different ways in order to provide convenient lookups.
-type IfdIndex struct {
- RootIfd *Ifd
- Ifds []*Ifd
- Tree map[int]*Ifd
- Lookup map[string]*Ifd
-}
-
-// Collect enumerates the different EXIF blocks (called IFDs) and builds out an
-// index struct for referencing all of the parsed data.
-func (ie *IfdEnumerate) Collect(rootIfdOffset uint32) (index IfdIndex, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add MiscellaneousExifData to IfdIndex
-
- tree := make(map[int]*Ifd)
- ifds := make([]*Ifd, 0)
- lookup := make(map[string]*Ifd)
-
- queue := []QueuedIfd{
- {
- IfdIdentity: exifcommon.IfdStandardIfdIdentity,
- Offset: rootIfdOffset,
- },
- }
-
- edges := make(map[uint32]*Ifd)
-
- for {
- if len(queue) == 0 {
- break
- }
-
- qi := queue[0]
- ii := qi.IfdIdentity
-
- offset := qi.Offset
- parentIfd := qi.Parent
-
- queue = queue[1:]
-
- ifdEnumerateLogger.Debugf(nil, "Parsing IFD [%s] (%d) at offset (0x%04x) (Collect).", ii.String(), ii.Index(), offset)
-
- bp, err := ie.getByteParser(offset)
- if err != nil {
- if err == ErrOffsetInvalid {
- return index, err
- }
-
- log.Panic(err)
- }
-
- // TODO(dustin): We don't need to pass the index in as a separate argument. Get from the II.
-
- nextIfdOffset, entries, thumbnailData, err := ie.parseIfd(ii, bp, nil, false, nil)
- log.PanicIf(err)
-
- currentOffset := bp.CurrentOffset()
- if currentOffset > ie.furthestOffset {
- ie.furthestOffset = currentOffset
- }
-
- id := len(ifds)
-
- entriesByTagId := make(map[uint16][]*IfdTagEntry)
- for _, ite := range entries {
- tagId := ite.TagId()
-
- tags, found := entriesByTagId[tagId]
- if found == false {
- tags = make([]*IfdTagEntry, 0)
- }
-
- entriesByTagId[tagId] = append(tags, ite)
- }
-
- ifd := &Ifd{
- ifdIdentity: ii,
-
- ByteOrder: ie.byteOrder,
-
- Id: id,
-
- ParentIfd: parentIfd,
- ParentTagIndex: qi.ParentTagIndex,
-
- Offset: offset,
- Entries: entries,
- EntriesByTagId: entriesByTagId,
-
- // This is populated as each child is processed.
- Children: make([]*Ifd, 0),
-
- NextIfdOffset: nextIfdOffset,
- thumbnailData: thumbnailData,
-
- ifdMapping: ie.ifdMapping,
- tagIndex: ie.tagIndex,
- }
-
- // Add ourselves to a big list of IFDs.
- ifds = append(ifds, ifd)
-
- // Install ourselves into a by-id lookup table (keys are unique).
- tree[id] = ifd
-
- // Install into by-name buckets.
- lookup[ii.String()] = ifd
-
- // Add a link from the previous IFD in the chain to us.
- if previousIfd, found := edges[offset]; found == true {
- previousIfd.NextIfd = ifd
- }
-
- // Attach as a child to our parent (where we appeared as a tag in
- // that IFD).
- if parentIfd != nil {
- parentIfd.Children = append(parentIfd.Children, ifd)
- }
-
- // Determine if any of our entries is a child IFD and queue it.
- for i, ite := range entries {
- if ite.ChildIfdPath() == "" {
- continue
- }
-
- tagId := ite.TagId()
- childIfdName := ite.ChildIfdName()
-
- currentIfdTag := ii.IfdTag()
-
- childIfdTag :=
- exifcommon.NewIfdTag(
- &currentIfdTag,
- tagId,
- childIfdName)
-
- iiChild := ii.NewChild(childIfdTag, 0)
-
- qi := QueuedIfd{
- IfdIdentity: iiChild,
-
- Offset: ite.getValueOffset(),
- Parent: ifd,
- ParentTagIndex: i,
- }
-
- queue = append(queue, qi)
- }
-
- // If there's another IFD in the chain.
- if nextIfdOffset != 0 {
- iiSibling := ii.NewSibling(ii.Index() + 1)
-
- // Allow the next link to know what the previous link was.
- edges[nextIfdOffset] = ifd
-
- qi := QueuedIfd{
- IfdIdentity: iiSibling,
- Offset: nextIfdOffset,
- }
-
- queue = append(queue, qi)
- }
- }
-
- index.RootIfd = tree[0]
- index.Ifds = ifds
- index.Tree = tree
- index.Lookup = lookup
-
- err = ie.setChildrenIndex(index.RootIfd)
- log.PanicIf(err)
-
- ifdEnumerateLogger.Debugf(nil, "Collect: It looks like the furthest offset that contained EXIF data in the EXIF blob was (%d).", ie.FurthestOffset())
-
- return index, nil
-}
-
-func (ie *IfdEnumerate) setChildrenIndex(ifd *Ifd) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- childIfdIndex := make(map[string]*Ifd)
- for _, childIfd := range ifd.Children {
- childIfdIndex[childIfd.ifdIdentity.UnindexedString()] = childIfd
- }
-
- ifd.ChildIfdIndex = childIfdIndex
-
- for _, childIfd := range ifd.Children {
- err := ie.setChildrenIndex(childIfd)
- log.PanicIf(err)
- }
-
- return nil
-}
-
-// FurthestOffset returns the furthest offset visited in the EXIF blob. This
-// *does not* account for the locations of any undefined tags since we always
-// evaluate the furthest offset, whether or not the user wants to know it.
-//
-// We are not willing to incur the cost of actually parsing those tags just to
-// know their length when there are still undefined tags that are out there
-// that we still won't have any idea how to parse, thus making this an
-// approximation regardless of how clever we get.
-func (ie *IfdEnumerate) FurthestOffset() uint32 {
-
- // TODO(dustin): Add test
-
- return ie.furthestOffset
-}
-
-// ParseOneIfd is a hack to use an IE to parse a raw IFD block. Can be used for
-// testing. The fqIfdPath ("fully-qualified IFD path") will be less qualified
-// in that the numeric index will always be zero (the zeroth child) rather than
-// the proper number (if its actually a sibling to the first child, for
-// instance).
-func ParseOneIfd(ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, ii *exifcommon.IfdIdentity, byteOrder binary.ByteOrder, ifdBlock []byte, visitor TagVisitorFn) (nextIfdOffset uint32, entries []*IfdTagEntry, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ie := NewIfdEnumerate(ifdMapping, tagIndex, make([]byte, 0), byteOrder)
-
- bp, err := newByteParser(ifdBlock, byteOrder, 0)
- if err != nil {
- if err == ErrOffsetInvalid {
- return 0, nil, err
- }
-
- log.Panic(err)
- }
-
- nextIfdOffset, entries, _, err = ie.parseIfd(ii, bp, visitor, true, nil)
- log.PanicIf(err)
-
- return nextIfdOffset, entries, nil
-}
-
-// ParseOneTag is a hack to use an IE to parse a raw tag block.
-func ParseOneTag(ifdMapping *exifcommon.IfdMapping, tagIndex *TagIndex, ii *exifcommon.IfdIdentity, byteOrder binary.ByteOrder, tagBlock []byte) (ite *IfdTagEntry, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- ie := NewIfdEnumerate(ifdMapping, tagIndex, make([]byte, 0), byteOrder)
-
- bp, err := newByteParser(tagBlock, byteOrder, 0)
- if err != nil {
- if err == ErrOffsetInvalid {
- return nil, err
- }
-
- log.Panic(err)
- }
-
- ite, err = ie.parseTag(ii, 0, bp)
- log.PanicIf(err)
-
- err = ie.postparseTag(ite, nil)
- if err != nil {
- if err == ErrTagNotFound {
- return nil, err
- }
-
- log.Panic(err)
- }
-
- return ite, nil
-}
-
-// FindIfdFromRootIfd returns the given `Ifd` given the root-IFD and path of the
-// desired IFD.
-func FindIfdFromRootIfd(rootIfd *Ifd, ifdPath string) (ifd *Ifd, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): !! Add test.
-
- lineage, err := rootIfd.ifdMapping.ResolvePath(ifdPath)
- log.PanicIf(err)
-
- // Confirm the first IFD is our root IFD type, and then prune it because
- // from then on we'll be searching down through our children.
-
- if len(lineage) == 0 {
- log.Panicf("IFD path must be non-empty.")
- } else if lineage[0].Name != exifcommon.IfdStandardIfdIdentity.Name() {
- log.Panicf("First IFD path item must be [%s].", exifcommon.IfdStandardIfdIdentity.Name())
- }
-
- desiredRootIndex := lineage[0].Index
- lineage = lineage[1:]
-
- // TODO(dustin): !! This is a poorly conceived fix that just doubles the work we already have to do below, which then interacts badly with the indices not being properly represented in the IFD-phrase.
- // TODO(dustin): !! <-- However, we're not sure whether we shouldn't store a secondary IFD-path with the indices. Some IFDs may not necessarily restrict which IFD indices they can be a child of (only the IFD itself matters). Validation should be delegated to the caller.
- thisIfd := rootIfd
- for currentRootIndex := 0; currentRootIndex < desiredRootIndex; currentRootIndex++ {
- if thisIfd.NextIfd == nil {
- log.Panicf("Root-IFD index (%d) does not exist in the data.", currentRootIndex)
- }
-
- thisIfd = thisIfd.NextIfd
- }
-
- for _, itii := range lineage {
- var hit *Ifd
- for _, childIfd := range thisIfd.Children {
- if childIfd.ifdIdentity.TagId() == itii.TagId {
- hit = childIfd
- break
- }
- }
-
- // If we didn't find the child, add it.
- if hit == nil {
- log.Panicf("IFD [%s] in [%s] not found: %s", itii.Name, ifdPath, thisIfd.Children)
- }
-
- thisIfd = hit
-
- // If we didn't find the sibling, add it.
- for i := 0; i < itii.Index; i++ {
- if thisIfd.NextIfd == nil {
- log.Panicf("IFD [%s] does not have (%d) occurrences/siblings", thisIfd.ifdIdentity.UnindexedString(), itii.Index)
- }
-
- thisIfd = thisIfd.NextIfd
- }
- }
-
- return thisIfd, nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/ifd_tag_entry.go b/vendor/github.com/dsoprea/go-exif/v2/ifd_tag_entry.go
deleted file mode 100644
index 789a9981c..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/ifd_tag_entry.go
+++ /dev/null
@@ -1,297 +0,0 @@
-package exif
-
-import (
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
- "github.com/dsoprea/go-exif/v2/undefined"
-)
-
-var (
- iteLogger = log.NewLogger("exif.ifd_tag_entry")
-)
-
-// IfdTagEntry refers to a tag in the loaded EXIF block.
-type IfdTagEntry struct {
- tagId uint16
- tagIndex int
- tagType exifcommon.TagTypePrimitive
- unitCount uint32
- valueOffset uint32
- rawValueOffset []byte
-
- // childIfdName is the right most atom in the IFD-path. We need this to
- // construct the fully-qualified IFD-path.
- childIfdName string
-
- // childIfdPath is the IFD-path of the child if this tag represents a child
- // IFD.
- childIfdPath string
-
- // childFqIfdPath is the IFD-path of the child if this tag represents a
- // child IFD. Includes indices.
- childFqIfdPath string
-
- // TODO(dustin): !! IB's host the child-IBs directly in the tag, but that's not the case here. Refactor to accommodate it for a consistent experience.
-
- ifdIdentity *exifcommon.IfdIdentity
-
- isUnhandledUnknown bool
-
- addressableData []byte
- byteOrder binary.ByteOrder
-
- tagName string
-}
-
-func newIfdTagEntry(ii *exifcommon.IfdIdentity, tagId uint16, tagIndex int, tagType exifcommon.TagTypePrimitive, unitCount uint32, valueOffset uint32, rawValueOffset []byte, addressableData []byte, byteOrder binary.ByteOrder) *IfdTagEntry {
- return &IfdTagEntry{
- ifdIdentity: ii,
- tagId: tagId,
- tagIndex: tagIndex,
- tagType: tagType,
- unitCount: unitCount,
- valueOffset: valueOffset,
- rawValueOffset: rawValueOffset,
- addressableData: addressableData,
- byteOrder: byteOrder,
- }
-}
-
-// String returns a stringified representation of the struct.
-func (ite *IfdTagEntry) String() string {
- return fmt.Sprintf("IfdTagEntry<TAG-IFD-PATH=[%s] TAG-ID=(0x%04x) TAG-TYPE=[%s] UNIT-COUNT=(%d)>", ite.ifdIdentity.String(), ite.tagId, ite.tagType.String(), ite.unitCount)
-}
-
-// TagName returns the name of the tag. This is determined else and set after
-// the parse (since it's not actually stored in the stream). If it's empty, it
-// is because it is an unknown tag (nonstandard or otherwise unavailable in the
-// tag-index).
-func (ite *IfdTagEntry) TagName() string {
- return ite.tagName
-}
-
-// setTagName sets the tag-name. This provides the name for convenience and
-// efficiency by determining it when most efficient while we're parsing rather
-// than delegating it to the caller (or, worse, the user).
-func (ite *IfdTagEntry) setTagName(tagName string) {
- ite.tagName = tagName
-}
-
-// IfdPath returns the fully-qualified path of the IFD that owns this tag.
-func (ite *IfdTagEntry) IfdPath() string {
- return ite.ifdIdentity.String()
-}
-
-// TagId returns the ID of the tag that we represent. The combination of
-// (IfdPath(), TagId()) is unique.
-func (ite *IfdTagEntry) TagId() uint16 {
- return ite.tagId
-}
-
-// IsThumbnailOffset returns true if the tag has the IFD and tag-ID of a
-// thumbnail offset.
-func (ite *IfdTagEntry) IsThumbnailOffset() bool {
- return ite.tagId == ThumbnailOffsetTagId && ite.ifdIdentity.String() == ThumbnailFqIfdPath
-}
-
-// IsThumbnailSize returns true if the tag has the IFD and tag-ID of a thumbnail
-// size.
-func (ite *IfdTagEntry) IsThumbnailSize() bool {
- return ite.tagId == ThumbnailSizeTagId && ite.ifdIdentity.String() == ThumbnailFqIfdPath
-}
-
-// TagType is the type of value for this tag.
-func (ite *IfdTagEntry) TagType() exifcommon.TagTypePrimitive {
- return ite.tagType
-}
-
-// updateTagType sets an alternatively interpreted tag-type.
-func (ite *IfdTagEntry) updateTagType(tagType exifcommon.TagTypePrimitive) {
- ite.tagType = tagType
-}
-
-// UnitCount returns the unit-count of the tag's value.
-func (ite *IfdTagEntry) UnitCount() uint32 {
- return ite.unitCount
-}
-
-// updateUnitCount sets an alternatively interpreted unit-count.
-func (ite *IfdTagEntry) updateUnitCount(unitCount uint32) {
- ite.unitCount = unitCount
-}
-
-// getValueOffset is the four-byte offset converted to an integer to point to
-// the location of its value in the EXIF block. The "get" parameter is obviously
-// used in order to differentiate the naming of the method from the field.
-func (ite *IfdTagEntry) getValueOffset() uint32 {
- return ite.valueOffset
-}
-
-// GetRawBytes renders a specific list of bytes from the value in this tag.
-func (ite *IfdTagEntry) GetRawBytes() (rawBytes []byte, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext := ite.getValueContext()
-
- if ite.tagType == exifcommon.TypeUndefined {
- value, err := exifundefined.Decode(valueContext)
- if err != nil {
- if err == exifcommon.ErrUnhandledUndefinedTypedTag {
- ite.setIsUnhandledUnknown(true)
- return nil, exifundefined.ErrUnparseableValue
- } else if err == exifundefined.ErrUnparseableValue {
- return nil, err
- } else {
- log.Panic(err)
- }
- }
-
- // Encode it back, in order to get the raw bytes. This is the best,
- // general way to do it with an undefined tag.
-
- rawBytes, _, err := exifundefined.Encode(value, ite.byteOrder)
- log.PanicIf(err)
-
- return rawBytes, nil
- }
-
- rawBytes, err = valueContext.ReadRawEncoded()
- log.PanicIf(err)
-
- return rawBytes, nil
-}
-
-// Value returns the specific, parsed, typed value from the tag.
-func (ite *IfdTagEntry) Value() (value interface{}, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext := ite.getValueContext()
-
- if ite.tagType == exifcommon.TypeUndefined {
- var err error
-
- value, err = exifundefined.Decode(valueContext)
- if err != nil {
- if err == exifcommon.ErrUnhandledUndefinedTypedTag || err == exifundefined.ErrUnparseableValue {
- return nil, err
- }
-
- log.Panic(err)
- }
- } else {
- var err error
-
- value, err = valueContext.Values()
- log.PanicIf(err)
- }
-
- return value, nil
-}
-
-// Format returns the tag's value as a string.
-func (ite *IfdTagEntry) Format() (phrase string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- value, err := ite.Value()
- if err != nil {
- if err == exifcommon.ErrUnhandledUndefinedTypedTag {
- return exifundefined.UnparseableUnknownTagValuePlaceholder, nil
- } else if err == exifundefined.ErrUnparseableValue {
- return exifundefined.UnparseableHandledTagValuePlaceholder, nil
- }
-
- log.Panic(err)
- }
-
- phrase, err = exifcommon.FormatFromType(value, false)
- log.PanicIf(err)
-
- return phrase, nil
-}
-
-// FormatFirst returns the same as Format() but only the first item.
-func (ite *IfdTagEntry) FormatFirst() (phrase string, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): We should add a convenience type "timestamp", to simplify translating to and from the physical ASCII and provide validation.
-
- value, err := ite.Value()
- if err != nil {
- if err == exifcommon.ErrUnhandledUndefinedTypedTag {
- return exifundefined.UnparseableUnknownTagValuePlaceholder, nil
- }
-
- log.Panic(err)
- }
-
- phrase, err = exifcommon.FormatFromType(value, true)
- log.PanicIf(err)
-
- return phrase, nil
-}
-
-func (ite *IfdTagEntry) setIsUnhandledUnknown(isUnhandledUnknown bool) {
- ite.isUnhandledUnknown = isUnhandledUnknown
-}
-
-// SetChildIfd sets child-IFD information (if we represent a child IFD).
-func (ite *IfdTagEntry) SetChildIfd(ii *exifcommon.IfdIdentity) {
- ite.childFqIfdPath = ii.String()
- ite.childIfdPath = ii.UnindexedString()
- ite.childIfdName = ii.Name()
-}
-
-// ChildIfdName returns the name of the child IFD
-func (ite *IfdTagEntry) ChildIfdName() string {
- return ite.childIfdName
-}
-
-// ChildIfdPath returns the path of the child IFD.
-func (ite *IfdTagEntry) ChildIfdPath() string {
- return ite.childIfdPath
-}
-
-// 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 (ite *IfdTagEntry) ChildFqIfdPath() string {
- return ite.childFqIfdPath
-}
-
-// IfdIdentity returns the IfdIdentity associated with this tag.
-func (ite *IfdTagEntry) IfdIdentity() *exifcommon.IfdIdentity {
- return ite.ifdIdentity
-}
-
-func (ite *IfdTagEntry) getValueContext() *exifcommon.ValueContext {
- return exifcommon.NewValueContext(
- ite.ifdIdentity.String(),
- ite.tagId,
- ite.unitCount,
- ite.valueOffset,
- ite.rawValueOffset,
- ite.addressableData,
- ite.tagType,
- ite.byteOrder)
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/package.go b/vendor/github.com/dsoprea/go-exif/v2/package.go
deleted file mode 100644
index 428f74e3a..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/package.go
+++ /dev/null
@@ -1,8 +0,0 @@
-// Package exif parses raw EXIF information given a block of raw EXIF data. It
-// can also construct new EXIF information, and provides tools for doing so.
-// This package is not involved with the parsing of particular file-formats.
-//
-// The EXIF data must first be extracted and then provided to us. Conversely,
-// when constructing new EXIF data, the caller is responsible for packaging
-// this in whichever format they require.
-package exif
diff --git a/vendor/github.com/dsoprea/go-exif/v2/tags.go b/vendor/github.com/dsoprea/go-exif/v2/tags.go
deleted file mode 100644
index f53d9ce9c..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/tags.go
+++ /dev/null
@@ -1,411 +0,0 @@
-package exif
-
-import (
- "fmt"
-
- "github.com/dsoprea/go-logging"
- "gopkg.in/yaml.v2"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-const (
- // IFD1
-
- // ThumbnailFqIfdPath is the fully-qualified IFD path that the thumbnail
- // must be found in.
- ThumbnailFqIfdPath = "IFD1"
-
- // ThumbnailOffsetTagId returns the tag-ID of the thumbnail offset.
- ThumbnailOffsetTagId = 0x0201
-
- // ThumbnailSizeTagId returns the tag-ID of the thumbnail size.
- ThumbnailSizeTagId = 0x0202
-)
-
-const (
- // GPS
-
- // TagGpsVersionId is the ID of the GPS version tag.
- TagGpsVersionId = 0x0000
-
- // TagLatitudeId is the ID of the GPS latitude tag.
- TagLatitudeId = 0x0002
-
- // TagLatitudeRefId is the ID of the GPS latitude orientation tag.
- TagLatitudeRefId = 0x0001
-
- // TagLongitudeId is the ID of the GPS longitude tag.
- TagLongitudeId = 0x0004
-
- // TagLongitudeRefId is the ID of the GPS longitude-orientation tag.
- TagLongitudeRefId = 0x0003
-
- // TagTimestampId is the ID of the GPS time tag.
- TagTimestampId = 0x0007
-
- // TagDatestampId is the ID of the GPS date tag.
- TagDatestampId = 0x001d
-
- // TagAltitudeId is the ID of the GPS altitude tag.
- TagAltitudeId = 0x0006
-
- // TagAltitudeRefId is the ID of the GPS altitude-orientation tag.
- TagAltitudeRefId = 0x0005
-)
-
-var (
- // tagsWithoutAlignment is a tag-lookup for tags whose value size won't
- // necessarily be a multiple of its tag-type.
- tagsWithoutAlignment = map[uint16]struct{}{
- // The thumbnail offset is stored as a long, but its data is a binary
- // blob (not a slice of longs).
- ThumbnailOffsetTagId: {},
- }
-)
-
-var (
- tagsLogger = log.NewLogger("exif.tags")
-)
-
-// File structures.
-
-type encodedTag struct {
- // id is signed, here, because YAML doesn't have enough information to
- // support unsigned.
- Id int `yaml:"id"`
- Name string `yaml:"name"`
- TypeName string `yaml:"type_name"`
- TypeNames []string `yaml:"type_names"`
-}
-
-// Indexing structures.
-
-// IndexedTag describes one index lookup result.
-type IndexedTag struct {
- // Id is the tag-ID.
- Id uint16
-
- // Name is the tag name.
- Name string
-
- // IfdPath is the proper IFD path of this tag. This is not fully-qualified.
- IfdPath string
-
- // SupportedTypes is an unsorted list of allowed tag-types.
- SupportedTypes []exifcommon.TagTypePrimitive
-}
-
-// String returns a descriptive string.
-func (it *IndexedTag) String() string {
- return fmt.Sprintf("TAG<ID=(0x%04x) NAME=[%s] IFD=[%s]>", it.Id, it.Name, it.IfdPath)
-}
-
-// IsName returns true if this tag matches the given tag name.
-func (it *IndexedTag) IsName(ifdPath, name string) bool {
- return it.Name == name && it.IfdPath == ifdPath
-}
-
-// Is returns true if this tag matched the given tag ID.
-func (it *IndexedTag) Is(ifdPath string, id uint16) bool {
- return it.Id == id && it.IfdPath == ifdPath
-}
-
-// GetEncodingType returns the largest type that this tag's value can occupy.
-func (it *IndexedTag) GetEncodingType(value interface{}) exifcommon.TagTypePrimitive {
- // For convenience, we handle encoding a `time.Time` directly.
- if IsTime(value) == true {
- // Timestamps are encoded as ASCII.
- value = ""
- }
-
- if len(it.SupportedTypes) == 0 {
- log.Panicf("IndexedTag [%s] (%d) has no supported types.", it.IfdPath, it.Id)
- } else if len(it.SupportedTypes) == 1 {
- return it.SupportedTypes[0]
- }
-
- supportsLong := false
- supportsShort := false
- supportsRational := false
- supportsSignedRational := false
- for _, supportedType := range it.SupportedTypes {
- if supportedType == exifcommon.TypeLong {
- supportsLong = true
- } else if supportedType == exifcommon.TypeShort {
- supportsShort = true
- } else if supportedType == exifcommon.TypeRational {
- supportsRational = true
- } else if supportedType == exifcommon.TypeSignedRational {
- supportsSignedRational = true
- }
- }
-
- // We specifically check for the cases that we know to expect.
-
- if supportsLong == true && supportsShort == true {
- return exifcommon.TypeLong
- } else if supportsRational == true && supportsSignedRational == true {
- if value == nil {
- log.Panicf("GetEncodingType: require value to be given")
- }
-
- if _, ok := value.(exifcommon.SignedRational); ok == true {
- return exifcommon.TypeSignedRational
- }
-
- return exifcommon.TypeRational
- }
-
- log.Panicf("WidestSupportedType() case is not handled for tag [%s] (0x%04x): %v", it.IfdPath, it.Id, it.SupportedTypes)
- return 0
-}
-
-// DoesSupportType returns true if this tag can be found/decoded with this type.
-func (it *IndexedTag) DoesSupportType(tagType exifcommon.TagTypePrimitive) bool {
- // This is always a very small collection. So, we keep it unsorted.
- for _, thisTagType := range it.SupportedTypes {
- if thisTagType == tagType {
- return true
- }
- }
-
- return false
-}
-
-// TagIndex is a tag-lookup facility.
-type TagIndex struct {
- tagsByIfd map[string]map[uint16]*IndexedTag
- tagsByIfdR map[string]map[string]*IndexedTag
-}
-
-// NewTagIndex returns a new TagIndex struct.
-func NewTagIndex() *TagIndex {
- ti := new(TagIndex)
-
- ti.tagsByIfd = make(map[string]map[uint16]*IndexedTag)
- ti.tagsByIfdR = make(map[string]map[string]*IndexedTag)
-
- return ti
-}
-
-// Add registers a new tag to be recognized during the parse.
-func (ti *TagIndex) Add(it *IndexedTag) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Store by ID.
-
- family, found := ti.tagsByIfd[it.IfdPath]
- if found == false {
- family = make(map[uint16]*IndexedTag)
- ti.tagsByIfd[it.IfdPath] = family
- }
-
- if _, found := family[it.Id]; found == true {
- log.Panicf("tag-ID defined more than once for IFD [%s]: (%02x)", it.IfdPath, it.Id)
- }
-
- family[it.Id] = it
-
- // Store by name.
-
- familyR, found := ti.tagsByIfdR[it.IfdPath]
- if found == false {
- familyR = make(map[string]*IndexedTag)
- ti.tagsByIfdR[it.IfdPath] = familyR
- }
-
- if _, found := familyR[it.Name]; found == true {
- log.Panicf("tag-name defined more than once for IFD [%s]: (%s)", it.IfdPath, it.Name)
- }
-
- familyR[it.Name] = it
-
- return nil
-}
-
-// Get returns information about the non-IFD tag given a tag ID. `ifdPath` must
-// not be fully-qualified.
-func (ti *TagIndex) Get(ii *exifcommon.IfdIdentity, id uint16) (it *IndexedTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if len(ti.tagsByIfd) == 0 {
- err := LoadStandardTags(ti)
- log.PanicIf(err)
- }
-
- ifdPath := ii.UnindexedString()
-
- family, found := ti.tagsByIfd[ifdPath]
- if found == false {
- return nil, ErrTagNotFound
- }
-
- it, found = family[id]
- if found == false {
- return nil, ErrTagNotFound
- }
-
- return it, nil
-}
-
-var (
- // tagGuessDefaultIfdIdentities describes which IFDs we'll look for a given
- // tag-ID in, if it's not found where it's supposed to be. We suppose that
- // Exif-IFD tags might be found in IFD0 or IFD1, or IFD0/IFD1 tags might be
- // found in the Exif IFD. This is the only thing we've seen so far. So, this
- // is the limit of our guessing.
- tagGuessDefaultIfdIdentities = []*exifcommon.IfdIdentity{
- exifcommon.IfdExifStandardIfdIdentity,
- exifcommon.IfdStandardIfdIdentity,
- }
-)
-
-// FindFirst looks for the given tag-ID in each of the given IFDs in the given
-// order. If `fqIfdPaths` is `nil` then use a default search order. This defies
-// the standard, which requires each tag to exist in certain IFDs. This is a
-// contingency to make recommendations for malformed data.
-//
-// Things *can* end badly here, in that the same tag-ID in different IFDs might
-// describe different data and different ata-types, and our decode might then
-// produce binary and non-printable data.
-func (ti *TagIndex) FindFirst(id uint16, typeId exifcommon.TagTypePrimitive, ifdIdentities []*exifcommon.IfdIdentity) (it *IndexedTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if ifdIdentities == nil {
- ifdIdentities = tagGuessDefaultIfdIdentities
- }
-
- for _, ii := range ifdIdentities {
- it, err := ti.Get(ii, id)
- if err != nil {
- if err == ErrTagNotFound {
- continue
- }
-
- log.Panic(err)
- }
-
- // Even though the tag might be mislocated, the type should still be the
- // same. Check this so we don't accidentally end-up on a complete
- // irrelevant tag with a totally different data type. This attempts to
- // mitigate producing garbage.
- for _, supportedType := range it.SupportedTypes {
- if supportedType == typeId {
- return it, nil
- }
- }
- }
-
- return nil, ErrTagNotFound
-}
-
-// GetWithName returns information about the non-IFD tag given a tag name.
-func (ti *TagIndex) GetWithName(ii *exifcommon.IfdIdentity, name string) (it *IndexedTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- if len(ti.tagsByIfdR) == 0 {
- err := LoadStandardTags(ti)
- log.PanicIf(err)
- }
-
- ifdPath := ii.UnindexedString()
-
- it, found := ti.tagsByIfdR[ifdPath][name]
- if found != true {
- log.Panic(ErrTagNotFound)
- }
-
- return it, nil
-}
-
-// LoadStandardTags registers the tags that all devices/applications should
-// support.
-func LoadStandardTags(ti *TagIndex) (err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // Read static data.
-
- encodedIfds := make(map[string][]encodedTag)
-
- err = yaml.Unmarshal([]byte(tagsYaml), encodedIfds)
- log.PanicIf(err)
-
- // Load structure.
-
- count := 0
- for ifdPath, tags := range encodedIfds {
- for _, tagInfo := range tags {
- tagId := uint16(tagInfo.Id)
- tagName := tagInfo.Name
- tagTypeName := tagInfo.TypeName
- tagTypeNames := tagInfo.TypeNames
-
- if tagTypeNames == nil {
- if tagTypeName == "" {
- log.Panicf("no tag-types were given when registering standard tag [%s] (0x%04x) [%s]", ifdPath, tagId, tagName)
- }
-
- tagTypeNames = []string{
- tagTypeName,
- }
- } else if tagTypeName != "" {
- log.Panicf("both 'type_names' and 'type_name' were given when registering standard tag [%s] (0x%04x) [%s]", ifdPath, tagId, tagName)
- }
-
- tagTypes := make([]exifcommon.TagTypePrimitive, 0)
- for _, tagTypeName := range tagTypeNames {
-
- // TODO(dustin): Discard unsupported types. This helps us with non-standard types that have actually been found in real data, that we ignore for right now. e.g. SSHORT, FLOAT, DOUBLE
- tagTypeId, found := exifcommon.GetTypeByName(tagTypeName)
- if found == false {
- tagsLogger.Warningf(nil, "Type [%s] for tag [%s] being loaded is not valid and is being ignored.", tagTypeName, tagName)
- continue
- }
-
- tagTypes = append(tagTypes, tagTypeId)
- }
-
- if len(tagTypes) == 0 {
- tagsLogger.Warningf(nil, "Tag [%s] (0x%04x) [%s] being loaded does not have any supported types and will not be registered.", ifdPath, tagId, tagName)
- continue
- }
-
- it := &IndexedTag{
- IfdPath: ifdPath,
- Id: tagId,
- Name: tagName,
- SupportedTypes: tagTypes,
- }
-
- err = ti.Add(it)
- log.PanicIf(err)
-
- count++
- }
- }
-
- tagsLogger.Debugf(nil, "(%d) tags loaded.", count)
-
- return nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/tags_data.go b/vendor/github.com/dsoprea/go-exif/v2/tags_data.go
deleted file mode 100644
index a770e5597..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/tags_data.go
+++ /dev/null
@@ -1,929 +0,0 @@
-package exif
-
-var (
- // From assets/tags.yaml . Needs to be here so it's embedded in the binary.
- tagsYaml = `
-# Notes:
-#
-# This file was produced from http://www.exiv2.org/tags.html, using the included
-# tool, though that document appears to have some duplicates when all IDs are
-# supposed to be unique (EXIF information only has IDs, not IFDs; IFDs are
-# determined by our pre-existing knowledge of those tags).
-#
-# The webpage that we've produced this file from appears to indicate that
-# ImageWidth is represented by both 0x0100 and 0x0001 depending on whether the
-# encoding is RGB or YCbCr.
-IFD/Exif:
-- id: 0x829a
- name: ExposureTime
- type_name: RATIONAL
-- id: 0x829d
- name: FNumber
- type_name: RATIONAL
-- id: 0x8822
- name: ExposureProgram
- type_name: SHORT
-- id: 0x8824
- name: SpectralSensitivity
- type_name: ASCII
-- id: 0x8827
- name: ISOSpeedRatings
- type_name: SHORT
-- id: 0x8828
- name: OECF
- type_name: UNDEFINED
-- id: 0x8830
- name: SensitivityType
- type_name: SHORT
-- id: 0x8831
- name: StandardOutputSensitivity
- type_name: LONG
-- id: 0x8832
- name: RecommendedExposureIndex
- type_name: LONG
-- id: 0x8833
- name: ISOSpeed
- type_name: LONG
-- id: 0x8834
- name: ISOSpeedLatitudeyyy
- type_name: LONG
-- id: 0x8835
- name: ISOSpeedLatitudezzz
- type_name: LONG
-- id: 0x9000
- name: ExifVersion
- type_name: UNDEFINED
-- id: 0x9003
- name: DateTimeOriginal
- type_name: ASCII
-- id: 0x9004
- name: DateTimeDigitized
- type_name: ASCII
-- id: 0x9101
- name: ComponentsConfiguration
- type_name: UNDEFINED
-- id: 0x9102
- name: CompressedBitsPerPixel
- type_name: RATIONAL
-- id: 0x9201
- name: ShutterSpeedValue
- type_name: SRATIONAL
-- id: 0x9202
- name: ApertureValue
- type_name: RATIONAL
-- id: 0x9203
- name: BrightnessValue
- type_name: SRATIONAL
-- id: 0x9204
- name: ExposureBiasValue
- type_name: SRATIONAL
-- id: 0x9205
- name: MaxApertureValue
- type_name: RATIONAL
-- id: 0x9206
- name: SubjectDistance
- type_name: RATIONAL
-- id: 0x9207
- name: MeteringMode
- type_name: SHORT
-- id: 0x9208
- name: LightSource
- type_name: SHORT
-- id: 0x9209
- name: Flash
- type_name: SHORT
-- id: 0x920a
- name: FocalLength
- type_name: RATIONAL
-- id: 0x9214
- name: SubjectArea
- type_name: SHORT
-- id: 0x927c
- name: MakerNote
- type_name: UNDEFINED
-- id: 0x9286
- name: UserComment
- type_name: UNDEFINED
-- id: 0x9290
- name: SubSecTime
- type_name: ASCII
-- id: 0x9291
- name: SubSecTimeOriginal
- type_name: ASCII
-- id: 0x9292
- name: SubSecTimeDigitized
- type_name: ASCII
-- id: 0xa000
- name: FlashpixVersion
- type_name: UNDEFINED
-- id: 0xa001
- name: ColorSpace
- type_name: SHORT
-- id: 0xa002
- name: PixelXDimension
- type_names: [LONG, SHORT]
-- id: 0xa003
- name: PixelYDimension
- type_names: [LONG, SHORT]
-- id: 0xa004
- name: RelatedSoundFile
- type_name: ASCII
-- id: 0xa005
- name: InteroperabilityTag
- type_name: LONG
-- id: 0xa20b
- name: FlashEnergy
- type_name: RATIONAL
-- id: 0xa20c
- name: SpatialFrequencyResponse
- type_name: UNDEFINED
-- id: 0xa20e
- name: FocalPlaneXResolution
- type_name: RATIONAL
-- id: 0xa20f
- name: FocalPlaneYResolution
- type_name: RATIONAL
-- id: 0xa210
- name: FocalPlaneResolutionUnit
- type_name: SHORT
-- id: 0xa214
- name: SubjectLocation
- type_name: SHORT
-- id: 0xa215
- name: ExposureIndex
- type_name: RATIONAL
-- id: 0xa217
- name: SensingMethod
- type_name: SHORT
-- id: 0xa300
- name: FileSource
- type_name: UNDEFINED
-- id: 0xa301
- name: SceneType
- type_name: UNDEFINED
-- id: 0xa302
- name: CFAPattern
- type_name: UNDEFINED
-- id: 0xa401
- name: CustomRendered
- type_name: SHORT
-- id: 0xa402
- name: ExposureMode
- type_name: SHORT
-- id: 0xa403
- name: WhiteBalance
- type_name: SHORT
-- id: 0xa404
- name: DigitalZoomRatio
- type_name: RATIONAL
-- id: 0xa405
- name: FocalLengthIn35mmFilm
- type_name: SHORT
-- id: 0xa406
- name: SceneCaptureType
- type_name: SHORT
-- id: 0xa407
- name: GainControl
- type_name: SHORT
-- id: 0xa408
- name: Contrast
- type_name: SHORT
-- id: 0xa409
- name: Saturation
- type_name: SHORT
-- id: 0xa40a
- name: Sharpness
- type_name: SHORT
-- id: 0xa40b
- name: DeviceSettingDescription
- type_name: UNDEFINED
-- id: 0xa40c
- name: SubjectDistanceRange
- type_name: SHORT
-- id: 0xa420
- name: ImageUniqueID
- type_name: ASCII
-- id: 0xa430
- name: CameraOwnerName
- type_name: ASCII
-- id: 0xa431
- name: BodySerialNumber
- type_name: ASCII
-- id: 0xa432
- name: LensSpecification
- type_name: RATIONAL
-- id: 0xa433
- name: LensMake
- type_name: ASCII
-- id: 0xa434
- name: LensModel
- type_name: ASCII
-- id: 0xa435
- name: LensSerialNumber
- type_name: ASCII
-IFD/GPSInfo:
-- id: 0x0000
- name: GPSVersionID
- type_name: BYTE
-- id: 0x0001
- name: GPSLatitudeRef
- type_name: ASCII
-- id: 0x0002
- name: GPSLatitude
- type_name: RATIONAL
-- id: 0x0003
- name: GPSLongitudeRef
- type_name: ASCII
-- id: 0x0004
- name: GPSLongitude
- type_name: RATIONAL
-- id: 0x0005
- name: GPSAltitudeRef
- type_name: BYTE
-- id: 0x0006
- name: GPSAltitude
- type_name: RATIONAL
-- id: 0x0007
- name: GPSTimeStamp
- type_name: RATIONAL
-- id: 0x0008
- name: GPSSatellites
- type_name: ASCII
-- id: 0x0009
- name: GPSStatus
- type_name: ASCII
-- id: 0x000a
- name: GPSMeasureMode
- type_name: ASCII
-- id: 0x000b
- name: GPSDOP
- type_name: RATIONAL
-- id: 0x000c
- name: GPSSpeedRef
- type_name: ASCII
-- id: 0x000d
- name: GPSSpeed
- type_name: RATIONAL
-- id: 0x000e
- name: GPSTrackRef
- type_name: ASCII
-- id: 0x000f
- name: GPSTrack
- type_name: RATIONAL
-- id: 0x0010
- name: GPSImgDirectionRef
- type_name: ASCII
-- id: 0x0011
- name: GPSImgDirection
- type_name: RATIONAL
-- id: 0x0012
- name: GPSMapDatum
- type_name: ASCII
-- id: 0x0013
- name: GPSDestLatitudeRef
- type_name: ASCII
-- id: 0x0014
- name: GPSDestLatitude
- type_name: RATIONAL
-- id: 0x0015
- name: GPSDestLongitudeRef
- type_name: ASCII
-- id: 0x0016
- name: GPSDestLongitude
- type_name: RATIONAL
-- id: 0x0017
- name: GPSDestBearingRef
- type_name: ASCII
-- id: 0x0018
- name: GPSDestBearing
- type_name: RATIONAL
-- id: 0x0019
- name: GPSDestDistanceRef
- type_name: ASCII
-- id: 0x001a
- name: GPSDestDistance
- type_name: RATIONAL
-- id: 0x001b
- name: GPSProcessingMethod
- type_name: UNDEFINED
-- id: 0x001c
- name: GPSAreaInformation
- type_name: UNDEFINED
-- id: 0x001d
- name: GPSDateStamp
- type_name: ASCII
-- id: 0x001e
- name: GPSDifferential
- type_name: SHORT
-IFD:
-- id: 0x000b
- name: ProcessingSoftware
- type_name: ASCII
-- id: 0x00fe
- name: NewSubfileType
- type_name: LONG
-- id: 0x00ff
- name: SubfileType
- type_name: SHORT
-- id: 0x0100
- name: ImageWidth
- type_names: [LONG, SHORT]
-- id: 0x0101
- name: ImageLength
- type_names: [LONG, SHORT]
-- id: 0x0102
- name: BitsPerSample
- type_name: SHORT
-- id: 0x0103
- name: Compression
- type_name: SHORT
-- id: 0x0106
- name: PhotometricInterpretation
- type_name: SHORT
-- id: 0x0107
- name: Thresholding
- type_name: SHORT
-- id: 0x0108
- name: CellWidth
- type_name: SHORT
-- id: 0x0109
- name: CellLength
- type_name: SHORT
-- id: 0x010a
- name: FillOrder
- type_name: SHORT
-- id: 0x010d
- name: DocumentName
- type_name: ASCII
-- id: 0x010e
- name: ImageDescription
- type_name: ASCII
-- id: 0x010f
- name: Make
- type_name: ASCII
-- id: 0x0110
- name: Model
- type_name: ASCII
-- id: 0x0111
- name: StripOffsets
- type_names: [LONG, SHORT]
-- id: 0x0112
- name: Orientation
- type_name: SHORT
-- id: 0x0115
- name: SamplesPerPixel
- type_name: SHORT
-- id: 0x0116
- name: RowsPerStrip
- type_names: [LONG, SHORT]
-- id: 0x0117
- name: StripByteCounts
- type_names: [LONG, SHORT]
-- id: 0x011a
- name: XResolution
- type_name: RATIONAL
-- id: 0x011b
- name: YResolution
- type_name: RATIONAL
-- id: 0x011c
- name: PlanarConfiguration
- type_name: SHORT
-- id: 0x0122
- name: GrayResponseUnit
- type_name: SHORT
-- id: 0x0123
- name: GrayResponseCurve
- type_name: SHORT
-- id: 0x0124
- name: T4Options
- type_name: LONG
-- id: 0x0125
- name: T6Options
- type_name: LONG
-- id: 0x0128
- name: ResolutionUnit
- type_name: SHORT
-- id: 0x0129
- name: PageNumber
- type_name: SHORT
-- id: 0x012d
- name: TransferFunction
- type_name: SHORT
-- id: 0x0131
- name: Software
- type_name: ASCII
-- id: 0x0132
- name: DateTime
- type_name: ASCII
-- id: 0x013b
- name: Artist
- type_name: ASCII
-- id: 0x013c
- name: HostComputer
- type_name: ASCII
-- id: 0x013d
- name: Predictor
- type_name: SHORT
-- id: 0x013e
- name: WhitePoint
- type_name: RATIONAL
-- id: 0x013f
- name: PrimaryChromaticities
- type_name: RATIONAL
-- id: 0x0140
- name: ColorMap
- type_name: SHORT
-- id: 0x0141
- name: HalftoneHints
- type_name: SHORT
-- id: 0x0142
- name: TileWidth
- type_name: SHORT
-- id: 0x0143
- name: TileLength
- type_name: SHORT
-- id: 0x0144
- name: TileOffsets
- type_name: SHORT
-- id: 0x0145
- name: TileByteCounts
- type_name: SHORT
-- id: 0x014a
- name: SubIFDs
- type_name: LONG
-- id: 0x014c
- name: InkSet
- type_name: SHORT
-- id: 0x014d
- name: InkNames
- type_name: ASCII
-- id: 0x014e
- name: NumberOfInks
- type_name: SHORT
-- id: 0x0150
- name: DotRange
- type_name: BYTE
-- id: 0x0151
- name: TargetPrinter
- type_name: ASCII
-- id: 0x0152
- name: ExtraSamples
- type_name: SHORT
-- id: 0x0153
- name: SampleFormat
- type_name: SHORT
-- id: 0x0154
- name: SMinSampleValue
- type_name: SHORT
-- id: 0x0155
- name: SMaxSampleValue
- type_name: SHORT
-- id: 0x0156
- name: TransferRange
- type_name: SHORT
-- id: 0x0157
- name: ClipPath
- type_name: BYTE
-- id: 0x015a
- name: Indexed
- type_name: SHORT
-- id: 0x015b
- name: JPEGTables
- type_name: UNDEFINED
-- id: 0x015f
- name: OPIProxy
- type_name: SHORT
-- id: 0x0200
- name: JPEGProc
- type_name: LONG
-- id: 0x0201
- name: JPEGInterchangeFormat
- type_name: LONG
-- id: 0x0202
- name: JPEGInterchangeFormatLength
- type_name: LONG
-- id: 0x0203
- name: JPEGRestartInterval
- type_name: SHORT
-- id: 0x0205
- name: JPEGLosslessPredictors
- type_name: SHORT
-- id: 0x0206
- name: JPEGPointTransforms
- type_name: SHORT
-- id: 0x0207
- name: JPEGQTables
- type_name: LONG
-- id: 0x0208
- name: JPEGDCTables
- type_name: LONG
-- id: 0x0209
- name: JPEGACTables
- type_name: LONG
-- id: 0x0211
- name: YCbCrCoefficients
- type_name: RATIONAL
-- id: 0x0212
- name: YCbCrSubSampling
- type_name: SHORT
-- id: 0x0213
- name: YCbCrPositioning
- type_name: SHORT
-- id: 0x0214
- name: ReferenceBlackWhite
- type_name: RATIONAL
-- id: 0x02bc
- name: XMLPacket
- type_name: BYTE
-- id: 0x4746
- name: Rating
- type_name: SHORT
-- id: 0x4749
- name: RatingPercent
- type_name: SHORT
-- id: 0x800d
- name: ImageID
- type_name: ASCII
-- id: 0x828d
- name: CFARepeatPatternDim
- type_name: SHORT
-- id: 0x828e
- name: CFAPattern
- type_name: BYTE
-- id: 0x828f
- name: BatteryLevel
- type_name: RATIONAL
-- id: 0x8298
- name: Copyright
- type_name: ASCII
-- id: 0x829a
- name: ExposureTime
-# NOTE(dustin): SRATIONAL isn't mentioned in the standard, but we have seen it in real data.
- type_names: [RATIONAL, SRATIONAL]
-- id: 0x829d
- name: FNumber
-# NOTE(dustin): SRATIONAL isn't mentioned in the standard, but we have seen it in real data.
- type_names: [RATIONAL, SRATIONAL]
-- id: 0x83bb
- name: IPTCNAA
- type_name: LONG
-- id: 0x8649
- name: ImageResources
- type_name: BYTE
-- id: 0x8769
- name: ExifTag
- type_name: LONG
-- id: 0x8773
- name: InterColorProfile
- type_name: UNDEFINED
-- id: 0x8822
- name: ExposureProgram
- type_name: SHORT
-- id: 0x8824
- name: SpectralSensitivity
- type_name: ASCII
-- id: 0x8825
- name: GPSTag
- type_name: LONG
-- id: 0x8827
- name: ISOSpeedRatings
- type_name: SHORT
-- id: 0x8828
- name: OECF
- type_name: UNDEFINED
-- id: 0x8829
- name: Interlace
- type_name: SHORT
-- id: 0x882b
- name: SelfTimerMode
- type_name: SHORT
-- id: 0x9003
- name: DateTimeOriginal
- type_name: ASCII
-- id: 0x9102
- name: CompressedBitsPerPixel
- type_name: RATIONAL
-- id: 0x9201
- name: ShutterSpeedValue
- type_name: SRATIONAL
-- id: 0x9202
- name: ApertureValue
- type_name: RATIONAL
-- id: 0x9203
- name: BrightnessValue
- type_name: SRATIONAL
-- id: 0x9204
- name: ExposureBiasValue
- type_name: SRATIONAL
-- id: 0x9205
- name: MaxApertureValue
- type_name: RATIONAL
-- id: 0x9206
- name: SubjectDistance
- type_name: SRATIONAL
-- id: 0x9207
- name: MeteringMode
- type_name: SHORT
-- id: 0x9208
- name: LightSource
- type_name: SHORT
-- id: 0x9209
- name: Flash
- type_name: SHORT
-- id: 0x920a
- name: FocalLength
- type_name: RATIONAL
-- id: 0x920b
- name: FlashEnergy
- type_name: RATIONAL
-- id: 0x920c
- name: SpatialFrequencyResponse
- type_name: UNDEFINED
-- id: 0x920d
- name: Noise
- type_name: UNDEFINED
-- id: 0x920e
- name: FocalPlaneXResolution
- type_name: RATIONAL
-- id: 0x920f
- name: FocalPlaneYResolution
- type_name: RATIONAL
-- id: 0x9210
- name: FocalPlaneResolutionUnit
- type_name: SHORT
-- id: 0x9211
- name: ImageNumber
- type_name: LONG
-- id: 0x9212
- name: SecurityClassification
- type_name: ASCII
-- id: 0x9213
- name: ImageHistory
- type_name: ASCII
-- id: 0x9214
- name: SubjectLocation
- type_name: SHORT
-- id: 0x9215
- name: ExposureIndex
- type_name: RATIONAL
-- id: 0x9216
- name: TIFFEPStandardID
- type_name: BYTE
-- id: 0x9217
- name: SensingMethod
- type_name: SHORT
-- id: 0x9c9b
- name: XPTitle
- type_name: BYTE
-- id: 0x9c9c
- name: XPComment
- type_name: BYTE
-- id: 0x9c9d
- name: XPAuthor
- type_name: BYTE
-- id: 0x9c9e
- name: XPKeywords
- type_name: BYTE
-- id: 0x9c9f
- name: XPSubject
- type_name: BYTE
-- id: 0xc4a5
- name: PrintImageMatching
- type_name: UNDEFINED
-- id: 0xc612
- name: DNGVersion
- type_name: BYTE
-- id: 0xc613
- name: DNGBackwardVersion
- type_name: BYTE
-- id: 0xc614
- name: UniqueCameraModel
- type_name: ASCII
-- id: 0xc615
- name: LocalizedCameraModel
- type_name: BYTE
-- id: 0xc616
- name: CFAPlaneColor
- type_name: BYTE
-- id: 0xc617
- name: CFALayout
- type_name: SHORT
-- id: 0xc618
- name: LinearizationTable
- type_name: SHORT
-- id: 0xc619
- name: BlackLevelRepeatDim
- type_name: SHORT
-- id: 0xc61a
- name: BlackLevel
- type_name: RATIONAL
-- id: 0xc61b
- name: BlackLevelDeltaH
- type_name: SRATIONAL
-- id: 0xc61c
- name: BlackLevelDeltaV
- type_name: SRATIONAL
-- id: 0xc61d
- name: WhiteLevel
- type_name: SHORT
-- id: 0xc61e
- name: DefaultScale
- type_name: RATIONAL
-- id: 0xc61f
- name: DefaultCropOrigin
- type_name: SHORT
-- id: 0xc620
- name: DefaultCropSize
- type_name: SHORT
-- id: 0xc621
- name: ColorMatrix1
- type_name: SRATIONAL
-- id: 0xc622
- name: ColorMatrix2
- type_name: SRATIONAL
-- id: 0xc623
- name: CameraCalibration1
- type_name: SRATIONAL
-- id: 0xc624
- name: CameraCalibration2
- type_name: SRATIONAL
-- id: 0xc625
- name: ReductionMatrix1
- type_name: SRATIONAL
-- id: 0xc626
- name: ReductionMatrix2
- type_name: SRATIONAL
-- id: 0xc627
- name: AnalogBalance
- type_name: RATIONAL
-- id: 0xc628
- name: AsShotNeutral
- type_name: SHORT
-- id: 0xc629
- name: AsShotWhiteXY
- type_name: RATIONAL
-- id: 0xc62a
- name: BaselineExposure
- type_name: SRATIONAL
-- id: 0xc62b
- name: BaselineNoise
- type_name: RATIONAL
-- id: 0xc62c
- name: BaselineSharpness
- type_name: RATIONAL
-- id: 0xc62d
- name: BayerGreenSplit
- type_name: LONG
-- id: 0xc62e
- name: LinearResponseLimit
- type_name: RATIONAL
-- id: 0xc62f
- name: CameraSerialNumber
- type_name: ASCII
-- id: 0xc630
- name: LensInfo
- type_name: RATIONAL
-- id: 0xc631
- name: ChromaBlurRadius
- type_name: RATIONAL
-- id: 0xc632
- name: AntiAliasStrength
- type_name: RATIONAL
-- id: 0xc633
- name: ShadowScale
- type_name: SRATIONAL
-- id: 0xc634
- name: DNGPrivateData
- type_name: BYTE
-- id: 0xc635
- name: MakerNoteSafety
- type_name: SHORT
-- id: 0xc65a
- name: CalibrationIlluminant1
- type_name: SHORT
-- id: 0xc65b
- name: CalibrationIlluminant2
- type_name: SHORT
-- id: 0xc65c
- name: BestQualityScale
- type_name: RATIONAL
-- id: 0xc65d
- name: RawDataUniqueID
- type_name: BYTE
-- id: 0xc68b
- name: OriginalRawFileName
- type_name: BYTE
-- id: 0xc68c
- name: OriginalRawFileData
- type_name: UNDEFINED
-- id: 0xc68d
- name: ActiveArea
- type_name: SHORT
-- id: 0xc68e
- name: MaskedAreas
- type_name: SHORT
-- id: 0xc68f
- name: AsShotICCProfile
- type_name: UNDEFINED
-- id: 0xc690
- name: AsShotPreProfileMatrix
- type_name: SRATIONAL
-- id: 0xc691
- name: CurrentICCProfile
- type_name: UNDEFINED
-- id: 0xc692
- name: CurrentPreProfileMatrix
- type_name: SRATIONAL
-- id: 0xc6bf
- name: ColorimetricReference
- type_name: SHORT
-- id: 0xc6f3
- name: CameraCalibrationSignature
- type_name: BYTE
-- id: 0xc6f4
- name: ProfileCalibrationSignature
- type_name: BYTE
-- id: 0xc6f6
- name: AsShotProfileName
- type_name: BYTE
-- id: 0xc6f7
- name: NoiseReductionApplied
- type_name: RATIONAL
-- id: 0xc6f8
- name: ProfileName
- type_name: BYTE
-- id: 0xc6f9
- name: ProfileHueSatMapDims
- type_name: LONG
-- id: 0xc6fd
- name: ProfileEmbedPolicy
- type_name: LONG
-- id: 0xc6fe
- name: ProfileCopyright
- type_name: BYTE
-- id: 0xc714
- name: ForwardMatrix1
- type_name: SRATIONAL
-- id: 0xc715
- name: ForwardMatrix2
- type_name: SRATIONAL
-- id: 0xc716
- name: PreviewApplicationName
- type_name: BYTE
-- id: 0xc717
- name: PreviewApplicationVersion
- type_name: BYTE
-- id: 0xc718
- name: PreviewSettingsName
- type_name: BYTE
-- id: 0xc719
- name: PreviewSettingsDigest
- type_name: BYTE
-- id: 0xc71a
- name: PreviewColorSpace
- type_name: LONG
-- id: 0xc71b
- name: PreviewDateTime
- type_name: ASCII
-- id: 0xc71c
- name: RawImageDigest
- type_name: UNDEFINED
-- id: 0xc71d
- name: OriginalRawFileDigest
- type_name: UNDEFINED
-- id: 0xc71e
- name: SubTileBlockSize
- type_name: LONG
-- id: 0xc71f
- name: RowInterleaveFactor
- type_name: LONG
-- id: 0xc725
- name: ProfileLookTableDims
- type_name: LONG
-- id: 0xc740
- name: OpcodeList1
- type_name: UNDEFINED
-- id: 0xc741
- name: OpcodeList2
- type_name: UNDEFINED
-- id: 0xc74e
- name: OpcodeList3
- type_name: UNDEFINED
-IFD/Exif/Iop:
-- id: 0x0001
- name: InteroperabilityIndex
- type_name: ASCII
-- id: 0x0002
- name: InteroperabilityVersion
- type_name: UNDEFINED
-- id: 0x1000
- name: RelatedImageFileFormat
- type_name: ASCII
-- id: 0x1001
- name: RelatedImageWidth
- type_name: LONG
-- id: 0x1002
- name: RelatedImageLength
- type_name: LONG
-`
-)
diff --git a/vendor/github.com/dsoprea/go-exif/v2/testing_common.go b/vendor/github.com/dsoprea/go-exif/v2/testing_common.go
deleted file mode 100644
index fe69df936..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/testing_common.go
+++ /dev/null
@@ -1,182 +0,0 @@
-package exif
-
-import (
- "path"
- "reflect"
- "testing"
-
- "io/ioutil"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-var (
- testExifData []byte
-)
-
-func getExifSimpleTestIb() *IfdBuilder {
- defer func() {
- if state := recover(); state != nil {
- err := log.Wrap(state.(error))
- log.Panic(err)
- }
- }()
-
- im := NewIfdMapping()
-
- err := LoadStandardIfds(im)
- log.PanicIf(err)
-
- ti := NewTagIndex()
- ib := NewIfdBuilder(im, ti, exifcommon.IfdStandardIfdIdentity, exifcommon.TestDefaultByteOrder)
-
- err = ib.AddStandard(0x000b, "asciivalue")
- log.PanicIf(err)
-
- err = ib.AddStandard(0x00ff, []uint16{0x1122})
- log.PanicIf(err)
-
- err = ib.AddStandard(0x0100, []uint32{0x33445566})
- log.PanicIf(err)
-
- err = ib.AddStandard(0x013e, []exifcommon.Rational{{Numerator: 0x11112222, Denominator: 0x33334444}})
- log.PanicIf(err)
-
- return ib
-}
-
-func getExifSimpleTestIbBytes() []byte {
- defer func() {
- if state := recover(); state != nil {
- err := log.Wrap(state.(error))
- log.Panic(err)
- }
- }()
-
- im := NewIfdMapping()
-
- err := LoadStandardIfds(im)
- log.PanicIf(err)
-
- ti := NewTagIndex()
- ib := NewIfdBuilder(im, ti, exifcommon.IfdStandardIfdIdentity, exifcommon.TestDefaultByteOrder)
-
- err = ib.AddStandard(0x000b, "asciivalue")
- log.PanicIf(err)
-
- err = ib.AddStandard(0x00ff, []uint16{0x1122})
- log.PanicIf(err)
-
- err = ib.AddStandard(0x0100, []uint32{0x33445566})
- log.PanicIf(err)
-
- err = ib.AddStandard(0x013e, []exifcommon.Rational{{Numerator: 0x11112222, Denominator: 0x33334444}})
- log.PanicIf(err)
-
- ibe := NewIfdByteEncoder()
-
- exifData, err := ibe.EncodeToExif(ib)
- log.PanicIf(err)
-
- return exifData
-}
-
-func validateExifSimpleTestIb(exifData []byte, t *testing.T) {
- defer func() {
- if state := recover(); state != nil {
- err := log.Wrap(state.(error))
- log.Panic(err)
- }
- }()
-
- im := NewIfdMapping()
-
- err := LoadStandardIfds(im)
- log.PanicIf(err)
-
- ti := NewTagIndex()
-
- eh, index, err := Collect(im, ti, exifData)
- log.PanicIf(err)
-
- if eh.ByteOrder != exifcommon.TestDefaultByteOrder {
- t.Fatalf("EXIF byte-order is not correct: %v", eh.ByteOrder)
- } else if eh.FirstIfdOffset != ExifDefaultFirstIfdOffset {
- t.Fatalf("EXIF first IFD-offset not correct: (0x%02x)", eh.FirstIfdOffset)
- }
-
- if len(index.Ifds) != 1 {
- t.Fatalf("There wasn't exactly one IFD decoded: (%d)", len(index.Ifds))
- }
-
- ifd := index.RootIfd
-
- if ifd.ByteOrder != exifcommon.TestDefaultByteOrder {
- t.Fatalf("IFD byte-order not correct.")
- } else if ifd.ifdIdentity.UnindexedString() != exifcommon.IfdStandardIfdIdentity.UnindexedString() {
- t.Fatalf("IFD name not correct.")
- } else if ifd.ifdIdentity.Index() != 0 {
- t.Fatalf("IFD index not zero: (%d)", ifd.ifdIdentity.Index())
- } else if ifd.Offset != uint32(0x0008) {
- t.Fatalf("IFD offset not correct.")
- } else if len(ifd.Entries) != 4 {
- t.Fatalf("IFD number of entries not correct: (%d)", len(ifd.Entries))
- } else if ifd.NextIfdOffset != uint32(0) {
- t.Fatalf("Next-IFD offset is non-zero.")
- } else if ifd.NextIfd != nil {
- t.Fatalf("Next-IFD pointer is non-nil.")
- }
-
- // Verify the values by using the actual, original types (this is awesome).
-
- expected := []struct {
- tagId uint16
- value interface{}
- }{
- {tagId: 0x000b, value: "asciivalue"},
- {tagId: 0x00ff, value: []uint16{0x1122}},
- {tagId: 0x0100, value: []uint32{0x33445566}},
- {tagId: 0x013e, value: []exifcommon.Rational{{Numerator: 0x11112222, Denominator: 0x33334444}}},
- }
-
- for i, ite := range ifd.Entries {
- if ite.TagId() != expected[i].tagId {
- t.Fatalf("Tag-ID for entry (%d) not correct: (0x%02x) != (0x%02x)", i, ite.TagId(), expected[i].tagId)
- }
-
- value, err := ite.Value()
- log.PanicIf(err)
-
- if reflect.DeepEqual(value, expected[i].value) != true {
- t.Fatalf("Value for entry (%d) not correct: [%v] != [%v]", i, value, expected[i].value)
- }
- }
-}
-
-func getTestImageFilepath() string {
- assetsPath := exifcommon.GetTestAssetsPath()
- testImageFilepath := path.Join(assetsPath, "NDM_8901.jpg")
- return testImageFilepath
-}
-
-func getTestExifData() []byte {
- if testExifData == nil {
- assetsPath := exifcommon.GetTestAssetsPath()
- filepath := path.Join(assetsPath, "NDM_8901.jpg.exif")
-
- var err error
-
- testExifData, err = ioutil.ReadFile(filepath)
- log.PanicIf(err)
- }
-
- return testExifData
-}
-
-func getTestGpsImageFilepath() string {
- assetsPath := exifcommon.GetTestAssetsPath()
- testGpsImageFilepath := path.Join(assetsPath, "gps.jpg")
- return testGpsImageFilepath
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/README.md b/vendor/github.com/dsoprea/go-exif/v2/undefined/README.md
deleted file mode 100644
index d2caa6e51..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/README.md
+++ /dev/null
@@ -1,4 +0,0 @@
-
-## 0xa40b
-
-The specification is not specific/clear enough to be handled. Without a working example ,we're deferring until some point in the future when either we or someone else has a better understanding.
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/accessor.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/accessor.go
deleted file mode 100644
index 3e82c0f61..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/accessor.go
+++ /dev/null
@@ -1,62 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-// Encode encodes the given encodeable undefined value to bytes.
-func Encode(value EncodeableValue, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- encoderName := value.EncoderName()
-
- encoder, found := encoders[encoderName]
- if found == false {
- log.Panicf("no encoder registered for type [%s]", encoderName)
- }
-
- encoded, unitCount, err = encoder.Encode(value, byteOrder)
- log.PanicIf(err)
-
- return encoded, unitCount, nil
-}
-
-// Decode constructs a value from raw encoded bytes
-func Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- uth := UndefinedTagHandle{
- IfdPath: valueContext.IfdPath(),
- TagId: valueContext.TagId(),
- }
-
- decoder, found := decoders[uth]
- if found == false {
- // We have no choice but to return the error. We have no way of knowing how
- // much data there is without already knowing what data-type this tag is.
- return nil, exifcommon.ErrUnhandledUndefinedTypedTag
- }
-
- value, err = decoder.Decode(valueContext)
- if err != nil {
- if err == ErrUnparseableValue {
- return nil, err
- }
-
- log.Panic(err)
- }
-
- return value, nil
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_8828_oecf.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_8828_oecf.go
deleted file mode 100644
index 796d17ca7..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_8828_oecf.go
+++ /dev/null
@@ -1,148 +0,0 @@
-package exifundefined
-
-import (
- "bytes"
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag8828Oecf struct {
- Columns uint16
- Rows uint16
- ColumnNames []string
- Values []exifcommon.SignedRational
-}
-
-func (oecf Tag8828Oecf) String() string {
- return fmt.Sprintf("Tag8828Oecf<COLUMNS=(%d) ROWS=(%d)>", oecf.Columns, oecf.Rows)
-}
-
-func (oecf Tag8828Oecf) EncoderName() string {
- return "Codec8828Oecf"
-}
-
-type Codec8828Oecf struct {
-}
-
-func (Codec8828Oecf) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test
-
- oecf, ok := value.(Tag8828Oecf)
- if ok == false {
- log.Panicf("can only encode a Tag8828Oecf")
- }
-
- b := new(bytes.Buffer)
-
- err = binary.Write(b, byteOrder, oecf.Columns)
- log.PanicIf(err)
-
- err = binary.Write(b, byteOrder, oecf.Rows)
- log.PanicIf(err)
-
- for _, name := range oecf.ColumnNames {
- _, err := b.Write([]byte(name))
- log.PanicIf(err)
-
- _, err = b.Write([]byte{0})
- log.PanicIf(err)
- }
-
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- ed, err := ve.Encode(oecf.Values)
- log.PanicIf(err)
-
- _, err = b.Write(ed.Encoded)
- log.PanicIf(err)
-
- return b.Bytes(), uint32(b.Len()), nil
-}
-
-func (Codec8828Oecf) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test using known good data.
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- oecf := Tag8828Oecf{}
-
- oecf.Columns = valueContext.ByteOrder().Uint16(valueBytes[0:2])
- oecf.Rows = valueContext.ByteOrder().Uint16(valueBytes[2:4])
-
- columnNames := make([]string, oecf.Columns)
-
- // startAt is where the current column name starts.
- startAt := 4
-
- // offset is our current position.
- offset := startAt
-
- currentColumnNumber := uint16(0)
-
- for currentColumnNumber < oecf.Columns {
- if valueBytes[offset] == 0 {
- columnName := string(valueBytes[startAt:offset])
- if len(columnName) == 0 {
- log.Panicf("SFR column (%d) has zero length", currentColumnNumber)
- }
-
- columnNames[currentColumnNumber] = columnName
- currentColumnNumber++
-
- offset++
- startAt = offset
- continue
- }
-
- offset++
- }
-
- oecf.ColumnNames = columnNames
-
- rawRationalBytes := valueBytes[offset:]
-
- rationalSize := exifcommon.TypeSignedRational.Size()
- if len(rawRationalBytes)%rationalSize > 0 {
- log.Panicf("OECF signed-rationals not aligned: (%d) %% (%d) > 0", len(rawRationalBytes), rationalSize)
- }
-
- rationalCount := len(rawRationalBytes) / rationalSize
-
- parser := new(exifcommon.Parser)
-
- byteOrder := valueContext.ByteOrder()
-
- items, err := parser.ParseSignedRationals(rawRationalBytes, uint32(rationalCount), byteOrder)
- log.PanicIf(err)
-
- oecf.Values = items
-
- return oecf, nil
-}
-
-func init() {
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0x8828,
- Codec8828Oecf{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9000_exif_version.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9000_exif_version.go
deleted file mode 100644
index 19cfcc906..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9000_exif_version.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag9000ExifVersion struct {
- ExifVersion string
-}
-
-func (Tag9000ExifVersion) EncoderName() string {
- return "Codec9000ExifVersion"
-}
-
-func (ev Tag9000ExifVersion) String() string {
- return ev.ExifVersion
-}
-
-type Codec9000ExifVersion struct {
-}
-
-func (Codec9000ExifVersion) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- s, ok := value.(Tag9000ExifVersion)
- if ok == false {
- log.Panicf("can only encode a Tag9000ExifVersion")
- }
-
- return []byte(s.ExifVersion), uint32(len(s.ExifVersion)), nil
-}
-
-func (Codec9000ExifVersion) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
-
- valueString, err := valueContext.ReadAsciiNoNul()
- log.PanicIf(err)
-
- ev := Tag9000ExifVersion{
- ExifVersion: valueString,
- }
-
- return ev, nil
-}
-
-func init() {
- registerEncoder(
- Tag9000ExifVersion{},
- Codec9000ExifVersion{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0x9000,
- Codec9000ExifVersion{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9101_components_configuration.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9101_components_configuration.go
deleted file mode 100644
index 16a4b38e4..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9101_components_configuration.go
+++ /dev/null
@@ -1,124 +0,0 @@
-package exifundefined
-
-import (
- "bytes"
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-const (
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Y = 0x1
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Cb = 0x2
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Cr = 0x3
- TagUndefinedType_9101_ComponentsConfiguration_Channel_R = 0x4
- TagUndefinedType_9101_ComponentsConfiguration_Channel_G = 0x5
- TagUndefinedType_9101_ComponentsConfiguration_Channel_B = 0x6
-)
-
-const (
- TagUndefinedType_9101_ComponentsConfiguration_OTHER = iota
- TagUndefinedType_9101_ComponentsConfiguration_RGB = iota
- TagUndefinedType_9101_ComponentsConfiguration_YCBCR = iota
-)
-
-var (
- TagUndefinedType_9101_ComponentsConfiguration_Names = map[int]string{
- TagUndefinedType_9101_ComponentsConfiguration_OTHER: "OTHER",
- TagUndefinedType_9101_ComponentsConfiguration_RGB: "RGB",
- TagUndefinedType_9101_ComponentsConfiguration_YCBCR: "YCBCR",
- }
-
- TagUndefinedType_9101_ComponentsConfiguration_Configurations = map[int][]byte{
- TagUndefinedType_9101_ComponentsConfiguration_RGB: {
- TagUndefinedType_9101_ComponentsConfiguration_Channel_R,
- TagUndefinedType_9101_ComponentsConfiguration_Channel_G,
- TagUndefinedType_9101_ComponentsConfiguration_Channel_B,
- 0,
- },
-
- TagUndefinedType_9101_ComponentsConfiguration_YCBCR: {
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Y,
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Cb,
- TagUndefinedType_9101_ComponentsConfiguration_Channel_Cr,
- 0,
- },
- }
-)
-
-type TagExif9101ComponentsConfiguration struct {
- ConfigurationId int
- ConfigurationBytes []byte
-}
-
-func (TagExif9101ComponentsConfiguration) EncoderName() string {
- return "CodecExif9101ComponentsConfiguration"
-}
-
-func (cc TagExif9101ComponentsConfiguration) String() string {
- return fmt.Sprintf("Exif9101ComponentsConfiguration<ID=[%s] BYTES=%v>", TagUndefinedType_9101_ComponentsConfiguration_Names[cc.ConfigurationId], cc.ConfigurationBytes)
-}
-
-type CodecExif9101ComponentsConfiguration struct {
-}
-
-func (CodecExif9101ComponentsConfiguration) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- cc, ok := value.(TagExif9101ComponentsConfiguration)
- if ok == false {
- log.Panicf("can only encode a TagExif9101ComponentsConfiguration")
- }
-
- return cc.ConfigurationBytes, uint32(len(cc.ConfigurationBytes)), nil
-}
-
-func (CodecExif9101ComponentsConfiguration) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- for configurationId, configurationBytes := range TagUndefinedType_9101_ComponentsConfiguration_Configurations {
- if bytes.Equal(configurationBytes, valueBytes) == true {
- cc := TagExif9101ComponentsConfiguration{
- ConfigurationId: configurationId,
- ConfigurationBytes: valueBytes,
- }
-
- return cc, nil
- }
- }
-
- cc := TagExif9101ComponentsConfiguration{
- ConfigurationId: TagUndefinedType_9101_ComponentsConfiguration_OTHER,
- ConfigurationBytes: valueBytes,
- }
-
- return cc, nil
-}
-
-func init() {
- registerEncoder(
- TagExif9101ComponentsConfiguration{},
- CodecExif9101ComponentsConfiguration{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0x9101,
- CodecExif9101ComponentsConfiguration{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_927C_maker_note.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_927C_maker_note.go
deleted file mode 100644
index e0a52db2a..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_927C_maker_note.go
+++ /dev/null
@@ -1,114 +0,0 @@
-package exifundefined
-
-import (
- "fmt"
- "strings"
-
- "crypto/sha1"
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag927CMakerNote struct {
- MakerNoteType []byte
- MakerNoteBytes []byte
-}
-
-func (Tag927CMakerNote) EncoderName() string {
- return "Codec927CMakerNote"
-}
-
-func (mn Tag927CMakerNote) String() string {
- parts := make([]string, len(mn.MakerNoteType))
-
- for i, c := range mn.MakerNoteType {
- parts[i] = fmt.Sprintf("%02x", c)
- }
-
- h := sha1.New()
-
- _, err := h.Write(mn.MakerNoteBytes)
- log.PanicIf(err)
-
- digest := h.Sum(nil)
-
- return fmt.Sprintf("MakerNote<TYPE-ID=[%s] LEN=(%d) SHA1=[%020x]>", strings.Join(parts, " "), len(mn.MakerNoteBytes), digest)
-}
-
-type Codec927CMakerNote struct {
-}
-
-func (Codec927CMakerNote) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- mn, ok := value.(Tag927CMakerNote)
- if ok == false {
- log.Panicf("can only encode a Tag927CMakerNote")
- }
-
- // TODO(dustin): Confirm this size against the specification.
-
- return mn.MakerNoteBytes, uint32(len(mn.MakerNoteBytes)), nil
-}
-
-func (Codec927CMakerNote) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // MakerNote
- // TODO(dustin): !! This is the Wild Wild West. This very well might be a child IFD, but any and all OEM's define their own formats. If we're going to be writing changes and this is complete EXIF (which may not have the first eight bytes), it might be fine. However, if these are just IFDs they'll be relative to the main EXIF, this will invalidate the MakerNote data for IFDs and any other implementations that use offsets unless we can interpret them all. It be best to return to this later and just exclude this from being written for now, though means a loss of a wealth of image metadata.
- // -> We can also just blindly try to interpret as an IFD and just validate that it's looks good (maybe it will even have a 'next ifd' pointer that we can validate is 0x0).
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- // TODO(dustin): Doesn't work, but here as an example.
- // ie := NewIfdEnumerate(valueBytes, byteOrder)
-
- // // TODO(dustin): !! Validate types (might have proprietary types, but it might be worth splitting the list between valid and not valid; maybe fail if a certain proportion are invalid, or maybe aren't less then a certain small integer)?
- // ii, err := ie.Collect(0x0)
-
- // for _, entry := range ii.RootIfd.Entries {
- // fmt.Printf("ENTRY: 0x%02x %d\n", entry.TagId, entry.TagType)
- // }
-
- var makerNoteType []byte
- if len(valueBytes) >= 20 {
- makerNoteType = valueBytes[:20]
- } else {
- makerNoteType = valueBytes
- }
-
- mn := Tag927CMakerNote{
- MakerNoteType: makerNoteType,
-
- // MakerNoteBytes has the whole length of bytes. There's always
- // the chance that the first 20 bytes includes actual data.
- MakerNoteBytes: valueBytes,
- }
-
- return mn, nil
-}
-
-func init() {
- registerEncoder(
- Tag927CMakerNote{},
- Codec927CMakerNote{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0x927c,
- Codec927CMakerNote{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9286_user_comment.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9286_user_comment.go
deleted file mode 100644
index de07fe19e..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_9286_user_comment.go
+++ /dev/null
@@ -1,142 +0,0 @@
-package exifundefined
-
-import (
- "bytes"
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-var (
- exif9286Logger = log.NewLogger("exifundefined.exif_9286_user_comment")
-)
-
-const (
- TagUndefinedType_9286_UserComment_Encoding_ASCII = iota
- TagUndefinedType_9286_UserComment_Encoding_JIS = iota
- TagUndefinedType_9286_UserComment_Encoding_UNICODE = iota
- TagUndefinedType_9286_UserComment_Encoding_UNDEFINED = iota
-)
-
-var (
- TagUndefinedType_9286_UserComment_Encoding_Names = map[int]string{
- TagUndefinedType_9286_UserComment_Encoding_ASCII: "ASCII",
- TagUndefinedType_9286_UserComment_Encoding_JIS: "JIS",
- TagUndefinedType_9286_UserComment_Encoding_UNICODE: "UNICODE",
- TagUndefinedType_9286_UserComment_Encoding_UNDEFINED: "UNDEFINED",
- }
-
- TagUndefinedType_9286_UserComment_Encodings = map[int][]byte{
- TagUndefinedType_9286_UserComment_Encoding_ASCII: {'A', 'S', 'C', 'I', 'I', 0, 0, 0},
- TagUndefinedType_9286_UserComment_Encoding_JIS: {'J', 'I', 'S', 0, 0, 0, 0, 0},
- TagUndefinedType_9286_UserComment_Encoding_UNICODE: {'U', 'n', 'i', 'c', 'o', 'd', 'e', 0},
- TagUndefinedType_9286_UserComment_Encoding_UNDEFINED: {0, 0, 0, 0, 0, 0, 0, 0},
- }
-)
-
-type Tag9286UserComment struct {
- EncodingType int
- EncodingBytes []byte
-}
-
-func (Tag9286UserComment) EncoderName() string {
- return "Codec9286UserComment"
-}
-
-func (uc Tag9286UserComment) String() string {
- var valuePhrase string
-
- if uc.EncodingType == TagUndefinedType_9286_UserComment_Encoding_ASCII {
- return fmt.Sprintf("[ASCII] %s", string(uc.EncodingBytes))
- } else {
- if len(uc.EncodingBytes) <= 8 {
- valuePhrase = fmt.Sprintf("%v", uc.EncodingBytes)
- } else {
- valuePhrase = fmt.Sprintf("%v...", uc.EncodingBytes[:8])
- }
- }
-
- return fmt.Sprintf("UserComment<SIZE=(%d) ENCODING=[%s] V=%v LEN=(%d)>", len(uc.EncodingBytes), TagUndefinedType_9286_UserComment_Encoding_Names[uc.EncodingType], valuePhrase, len(uc.EncodingBytes))
-}
-
-type Codec9286UserComment struct {
-}
-
-func (Codec9286UserComment) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- uc, ok := value.(Tag9286UserComment)
- if ok == false {
- log.Panicf("can only encode a Tag9286UserComment")
- }
-
- encodingTypeBytes, found := TagUndefinedType_9286_UserComment_Encodings[uc.EncodingType]
- if found == false {
- log.Panicf("encoding-type not valid for unknown-type tag 9286 (UserComment): (%d)", uc.EncodingType)
- }
-
- encoded = make([]byte, len(uc.EncodingBytes)+8)
-
- copy(encoded[:8], encodingTypeBytes)
- copy(encoded[8:], uc.EncodingBytes)
-
- // TODO(dustin): Confirm this size against the specification.
-
- return encoded, uint32(len(encoded)), nil
-}
-
-func (Codec9286UserComment) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- if len(valueBytes) < 8 {
- return nil, ErrUnparseableValue
- }
-
- unknownUc := Tag9286UserComment{
- EncodingType: TagUndefinedType_9286_UserComment_Encoding_UNDEFINED,
- EncodingBytes: []byte{},
- }
-
- encoding := valueBytes[:8]
- for encodingIndex, encodingBytes := range TagUndefinedType_9286_UserComment_Encodings {
- if bytes.Compare(encoding, encodingBytes) == 0 {
- uc := Tag9286UserComment{
- EncodingType: encodingIndex,
- EncodingBytes: valueBytes[8:],
- }
-
- return uc, nil
- }
- }
-
- exif9286Logger.Warningf(nil, "User-comment encoding not valid. Returning 'unknown' type (the default).")
- return unknownUc, nil
-}
-
-func init() {
- registerEncoder(
- Tag9286UserComment{},
- Codec9286UserComment{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0x9286,
- Codec9286UserComment{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A000_flashpix_version.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A000_flashpix_version.go
deleted file mode 100644
index 28849cde5..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A000_flashpix_version.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type TagA000FlashpixVersion struct {
- FlashpixVersion string
-}
-
-func (TagA000FlashpixVersion) EncoderName() string {
- return "CodecA000FlashpixVersion"
-}
-
-func (fv TagA000FlashpixVersion) String() string {
- return fv.FlashpixVersion
-}
-
-type CodecA000FlashpixVersion struct {
-}
-
-func (CodecA000FlashpixVersion) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- s, ok := value.(TagA000FlashpixVersion)
- if ok == false {
- log.Panicf("can only encode a TagA000FlashpixVersion")
- }
-
- return []byte(s.FlashpixVersion), uint32(len(s.FlashpixVersion)), nil
-}
-
-func (CodecA000FlashpixVersion) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
-
- valueString, err := valueContext.ReadAsciiNoNul()
- log.PanicIf(err)
-
- fv := TagA000FlashpixVersion{
- FlashpixVersion: valueString,
- }
-
- return fv, nil
-}
-
-func init() {
- registerEncoder(
- TagA000FlashpixVersion{},
- CodecA000FlashpixVersion{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0xa000,
- CodecA000FlashpixVersion{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A20C_spatial_frequency_response.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A20C_spatial_frequency_response.go
deleted file mode 100644
index d49c8c52d..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A20C_spatial_frequency_response.go
+++ /dev/null
@@ -1,160 +0,0 @@
-package exifundefined
-
-import (
- "bytes"
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type TagA20CSpatialFrequencyResponse struct {
- Columns uint16
- Rows uint16
- ColumnNames []string
- Values []exifcommon.Rational
-}
-
-func (TagA20CSpatialFrequencyResponse) EncoderName() string {
- return "CodecA20CSpatialFrequencyResponse"
-}
-
-func (sfr TagA20CSpatialFrequencyResponse) String() string {
- return fmt.Sprintf("CodecA20CSpatialFrequencyResponse<COLUMNS=(%d) ROWS=(%d)>", sfr.Columns, sfr.Rows)
-}
-
-type CodecA20CSpatialFrequencyResponse struct {
-}
-
-func (CodecA20CSpatialFrequencyResponse) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test.
-
- sfr, ok := value.(TagA20CSpatialFrequencyResponse)
- if ok == false {
- log.Panicf("can only encode a TagA20CSpatialFrequencyResponse")
- }
-
- b := new(bytes.Buffer)
-
- err = binary.Write(b, byteOrder, sfr.Columns)
- log.PanicIf(err)
-
- err = binary.Write(b, byteOrder, sfr.Rows)
- log.PanicIf(err)
-
- // Write columns.
-
- for _, name := range sfr.ColumnNames {
- _, err := b.WriteString(name)
- log.PanicIf(err)
-
- err = b.WriteByte(0)
- log.PanicIf(err)
- }
-
- // Write values.
-
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- ed, err := ve.Encode(sfr.Values)
- log.PanicIf(err)
-
- _, err = b.Write(ed.Encoded)
- log.PanicIf(err)
-
- encoded = b.Bytes()
-
- // TODO(dustin): Confirm this size against the specification.
-
- return encoded, uint32(len(encoded)), nil
-}
-
-func (CodecA20CSpatialFrequencyResponse) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test using known good data.
-
- byteOrder := valueContext.ByteOrder()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- sfr := TagA20CSpatialFrequencyResponse{}
-
- sfr.Columns = byteOrder.Uint16(valueBytes[0:2])
- sfr.Rows = byteOrder.Uint16(valueBytes[2:4])
-
- columnNames := make([]string, sfr.Columns)
-
- // startAt is where the current column name starts.
- startAt := 4
-
- // offset is our current position.
- offset := 4
-
- currentColumnNumber := uint16(0)
-
- for currentColumnNumber < sfr.Columns {
- if valueBytes[offset] == 0 {
- columnName := string(valueBytes[startAt:offset])
- if len(columnName) == 0 {
- log.Panicf("SFR column (%d) has zero length", currentColumnNumber)
- }
-
- columnNames[currentColumnNumber] = columnName
- currentColumnNumber++
-
- offset++
- startAt = offset
- continue
- }
-
- offset++
- }
-
- sfr.ColumnNames = columnNames
-
- rawRationalBytes := valueBytes[offset:]
-
- rationalSize := exifcommon.TypeRational.Size()
- if len(rawRationalBytes)%rationalSize > 0 {
- log.Panicf("SFR rationals not aligned: (%d) %% (%d) > 0", len(rawRationalBytes), rationalSize)
- }
-
- rationalCount := len(rawRationalBytes) / rationalSize
-
- parser := new(exifcommon.Parser)
-
- items, err := parser.ParseRationals(rawRationalBytes, uint32(rationalCount), byteOrder)
- log.PanicIf(err)
-
- sfr.Values = items
-
- return sfr, nil
-}
-
-func init() {
- registerEncoder(
- TagA20CSpatialFrequencyResponse{},
- CodecA20CSpatialFrequencyResponse{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0xa20c,
- CodecA20CSpatialFrequencyResponse{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A300_file_source.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A300_file_source.go
deleted file mode 100644
index 18a7cdf63..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A300_file_source.go
+++ /dev/null
@@ -1,79 +0,0 @@
-package exifundefined
-
-import (
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type TagExifA300FileSource uint32
-
-func (TagExifA300FileSource) EncoderName() string {
- return "CodecExifA300FileSource"
-}
-
-func (af TagExifA300FileSource) String() string {
- return fmt.Sprintf("0x%08x", uint32(af))
-}
-
-const (
- TagUndefinedType_A300_SceneType_Others TagExifA300FileSource = 0
- TagUndefinedType_A300_SceneType_ScannerOfTransparentType TagExifA300FileSource = 1
- TagUndefinedType_A300_SceneType_ScannerOfReflexType TagExifA300FileSource = 2
- TagUndefinedType_A300_SceneType_Dsc TagExifA300FileSource = 3
-)
-
-type CodecExifA300FileSource struct {
-}
-
-func (CodecExifA300FileSource) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- st, ok := value.(TagExifA300FileSource)
- if ok == false {
- log.Panicf("can only encode a TagExifA300FileSource")
- }
-
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- ed, err := ve.Encode([]uint32{uint32(st)})
- log.PanicIf(err)
-
- // TODO(dustin): Confirm this size against the specification. It's non-specific about what type it is, but it looks to be no more than a single integer scalar. So, we're assuming it's a LONG.
-
- return ed.Encoded, 1, nil
-}
-
-func (CodecExifA300FileSource) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeLong)
-
- valueLongs, err := valueContext.ReadLongs()
- log.PanicIf(err)
-
- return TagExifA300FileSource(valueLongs[0]), nil
-}
-
-func init() {
- registerEncoder(
- TagExifA300FileSource(0),
- CodecExifA300FileSource{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0xa300,
- CodecExifA300FileSource{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A301_scene_type.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A301_scene_type.go
deleted file mode 100644
index b4246da18..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A301_scene_type.go
+++ /dev/null
@@ -1,76 +0,0 @@
-package exifundefined
-
-import (
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type TagExifA301SceneType uint32
-
-func (TagExifA301SceneType) EncoderName() string {
- return "CodecExifA301SceneType"
-}
-
-func (st TagExifA301SceneType) String() string {
- return fmt.Sprintf("0x%08x", uint32(st))
-}
-
-const (
- TagUndefinedType_A301_SceneType_DirectlyPhotographedImage TagExifA301SceneType = 1
-)
-
-type CodecExifA301SceneType struct {
-}
-
-func (CodecExifA301SceneType) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- st, ok := value.(TagExifA301SceneType)
- if ok == false {
- log.Panicf("can only encode a TagExif9101ComponentsConfiguration")
- }
-
- ve := exifcommon.NewValueEncoder(byteOrder)
-
- ed, err := ve.Encode([]uint32{uint32(st)})
- log.PanicIf(err)
-
- // TODO(dustin): Confirm this size against the specification. It's non-specific about what type it is, but it looks to be no more than a single integer scalar. So, we're assuming it's a LONG.
-
- return ed.Encoded, uint32(int(ed.UnitCount)), nil
-}
-
-func (CodecExifA301SceneType) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeLong)
-
- valueLongs, err := valueContext.ReadLongs()
- log.PanicIf(err)
-
- return TagExifA301SceneType(valueLongs[0]), nil
-}
-
-func init() {
- registerEncoder(
- TagExifA301SceneType(0),
- CodecExifA301SceneType{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0xa301,
- CodecExifA301SceneType{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A302_cfa_pattern.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A302_cfa_pattern.go
deleted file mode 100644
index beca78c23..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_A302_cfa_pattern.go
+++ /dev/null
@@ -1,97 +0,0 @@
-package exifundefined
-
-import (
- "bytes"
- "fmt"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type TagA302CfaPattern struct {
- HorizontalRepeat uint16
- VerticalRepeat uint16
- CfaValue []byte
-}
-
-func (TagA302CfaPattern) EncoderName() string {
- return "CodecA302CfaPattern"
-}
-
-func (cp TagA302CfaPattern) String() string {
- return fmt.Sprintf("TagA302CfaPattern<HORZ-REPEAT=(%d) VERT-REPEAT=(%d) CFA-VALUE=(%d)>", cp.HorizontalRepeat, cp.VerticalRepeat, len(cp.CfaValue))
-}
-
-type CodecA302CfaPattern struct {
-}
-
-func (CodecA302CfaPattern) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test.
-
- cp, ok := value.(TagA302CfaPattern)
- if ok == false {
- log.Panicf("can only encode a TagA302CfaPattern")
- }
-
- b := new(bytes.Buffer)
-
- err = binary.Write(b, byteOrder, cp.HorizontalRepeat)
- log.PanicIf(err)
-
- err = binary.Write(b, byteOrder, cp.VerticalRepeat)
- log.PanicIf(err)
-
- _, err = b.Write(cp.CfaValue)
- log.PanicIf(err)
-
- encoded = b.Bytes()
-
- // TODO(dustin): Confirm this size against the specification.
-
- return encoded, uint32(len(encoded)), nil
-}
-
-func (CodecA302CfaPattern) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- // TODO(dustin): Add test using known good data.
-
- valueContext.SetUndefinedValueType(exifcommon.TypeByte)
-
- valueBytes, err := valueContext.ReadBytes()
- log.PanicIf(err)
-
- cp := TagA302CfaPattern{}
-
- cp.HorizontalRepeat = valueContext.ByteOrder().Uint16(valueBytes[0:2])
- cp.VerticalRepeat = valueContext.ByteOrder().Uint16(valueBytes[2:4])
-
- expectedLength := int(cp.HorizontalRepeat * cp.VerticalRepeat)
- cp.CfaValue = valueBytes[4 : 4+expectedLength]
-
- return cp, nil
-}
-
-func init() {
- registerEncoder(
- TagA302CfaPattern{},
- CodecA302CfaPattern{})
-
- registerDecoder(
- exifcommon.IfdExifStandardIfdIdentity.UnindexedString(),
- 0xa302,
- CodecA302CfaPattern{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_iop_0002_interop_version.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_iop_0002_interop_version.go
deleted file mode 100644
index eca046b05..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/exif_iop_0002_interop_version.go
+++ /dev/null
@@ -1,69 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag0002InteropVersion struct {
- InteropVersion string
-}
-
-func (Tag0002InteropVersion) EncoderName() string {
- return "Codec0002InteropVersion"
-}
-
-func (iv Tag0002InteropVersion) String() string {
- return iv.InteropVersion
-}
-
-type Codec0002InteropVersion struct {
-}
-
-func (Codec0002InteropVersion) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- s, ok := value.(Tag0002InteropVersion)
- if ok == false {
- log.Panicf("can only encode a Tag0002InteropVersion")
- }
-
- return []byte(s.InteropVersion), uint32(len(s.InteropVersion)), nil
-}
-
-func (Codec0002InteropVersion) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
-
- valueString, err := valueContext.ReadAsciiNoNul()
- log.PanicIf(err)
-
- iv := Tag0002InteropVersion{
- InteropVersion: valueString,
- }
-
- return iv, nil
-}
-
-func init() {
- registerEncoder(
- Tag0002InteropVersion{},
- Codec0002InteropVersion{})
-
- registerDecoder(
- exifcommon.IfdExifIopStandardIfdIdentity.UnindexedString(),
- 0x0002,
- Codec0002InteropVersion{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001B_gps_processing_method.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001B_gps_processing_method.go
deleted file mode 100644
index 8583bfb27..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001B_gps_processing_method.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag001BGPSProcessingMethod struct {
- string
-}
-
-func (Tag001BGPSProcessingMethod) EncoderName() string {
- return "Codec001BGPSProcessingMethod"
-}
-
-func (gpm Tag001BGPSProcessingMethod) String() string {
- return gpm.string
-}
-
-type Codec001BGPSProcessingMethod struct {
-}
-
-func (Codec001BGPSProcessingMethod) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- s, ok := value.(Tag001BGPSProcessingMethod)
- if ok == false {
- log.Panicf("can only encode a Tag001BGPSProcessingMethod")
- }
-
- return []byte(s.string), uint32(len(s.string)), nil
-}
-
-func (Codec001BGPSProcessingMethod) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
-
- valueString, err := valueContext.ReadAsciiNoNul()
- log.PanicIf(err)
-
- return Tag001BGPSProcessingMethod{valueString}, nil
-}
-
-func init() {
- registerEncoder(
- Tag001BGPSProcessingMethod{},
- Codec001BGPSProcessingMethod{})
-
- registerDecoder(
- exifcommon.IfdGpsInfoStandardIfdIdentity.UnindexedString(),
- 0x001b,
- Codec001BGPSProcessingMethod{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001C_gps_area_information.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001C_gps_area_information.go
deleted file mode 100644
index 67acceb65..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/gps_001C_gps_area_information.go
+++ /dev/null
@@ -1,65 +0,0 @@
-package exifundefined
-
-import (
- "encoding/binary"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-type Tag001CGPSAreaInformation struct {
- string
-}
-
-func (Tag001CGPSAreaInformation) EncoderName() string {
- return "Codec001CGPSAreaInformation"
-}
-
-func (gai Tag001CGPSAreaInformation) String() string {
- return gai.string
-}
-
-type Codec001CGPSAreaInformation struct {
-}
-
-func (Codec001CGPSAreaInformation) Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- s, ok := value.(Tag001CGPSAreaInformation)
- if ok == false {
- log.Panicf("can only encode a Tag001CGPSAreaInformation")
- }
-
- return []byte(s.string), uint32(len(s.string)), nil
-}
-
-func (Codec001CGPSAreaInformation) Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- valueContext.SetUndefinedValueType(exifcommon.TypeAsciiNoNul)
-
- valueString, err := valueContext.ReadAsciiNoNul()
- log.PanicIf(err)
-
- return Tag001CGPSAreaInformation{valueString}, nil
-}
-
-func init() {
- registerEncoder(
- Tag001CGPSAreaInformation{},
- Codec001CGPSAreaInformation{})
-
- registerDecoder(
- exifcommon.IfdGpsInfoStandardIfdIdentity.UnindexedString(),
- 0x001c,
- Codec001CGPSAreaInformation{})
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/registration.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/registration.go
deleted file mode 100644
index cccc20a82..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/registration.go
+++ /dev/null
@@ -1,42 +0,0 @@
-package exifundefined
-
-import (
- "github.com/dsoprea/go-logging"
-)
-
-// UndefinedTagHandle defines one undefined-type tag with a corresponding
-// decoder.
-type UndefinedTagHandle struct {
- IfdPath string
- TagId uint16
-}
-
-func registerEncoder(entity EncodeableValue, encoder UndefinedValueEncoder) {
- typeName := entity.EncoderName()
-
- _, found := encoders[typeName]
- if found == true {
- log.Panicf("encoder already registered: %v", typeName)
- }
-
- encoders[typeName] = encoder
-}
-
-func registerDecoder(ifdPath string, tagId uint16, decoder UndefinedValueDecoder) {
- uth := UndefinedTagHandle{
- IfdPath: ifdPath,
- TagId: tagId,
- }
-
- _, found := decoders[uth]
- if found == true {
- log.Panicf("decoder already registered: %v", uth)
- }
-
- decoders[uth] = decoder
-}
-
-var (
- encoders = make(map[string]UndefinedValueEncoder)
- decoders = make(map[UndefinedTagHandle]UndefinedValueDecoder)
-)
diff --git a/vendor/github.com/dsoprea/go-exif/v2/undefined/type.go b/vendor/github.com/dsoprea/go-exif/v2/undefined/type.go
deleted file mode 100644
index 29890ef86..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/undefined/type.go
+++ /dev/null
@@ -1,44 +0,0 @@
-package exifundefined
-
-import (
- "errors"
-
- "encoding/binary"
-
- "github.com/dsoprea/go-exif/v2/common"
-)
-
-const (
- // UnparseableUnknownTagValuePlaceholder is the string to use for an unknown
- // undefined tag.
- UnparseableUnknownTagValuePlaceholder = "!UNKNOWN"
-
- // UnparseableHandledTagValuePlaceholder is the string to use for a known
- // value that is not parseable.
- UnparseableHandledTagValuePlaceholder = "!MALFORMED"
-)
-
-var (
- // ErrUnparseableValue is the error for a value that we should have been
- // able to parse but were not able to.
- ErrUnparseableValue = errors.New("unparseable undefined tag")
-)
-
-// UndefinedValueEncoder knows how to encode an undefined-type tag's value to
-// bytes.
-type UndefinedValueEncoder interface {
- Encode(value interface{}, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error)
-}
-
-// EncodeableValue wraps a value with the information that will be needed to re-
-// encode it later.
-type EncodeableValue interface {
- EncoderName() string
- String() string
-}
-
-// UndefinedValueDecoder knows how to decode an undefined-type tag's value from
-// bytes.
-type UndefinedValueDecoder interface {
- Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error)
-}
diff --git a/vendor/github.com/dsoprea/go-exif/v2/utility.go b/vendor/github.com/dsoprea/go-exif/v2/utility.go
deleted file mode 100644
index ad692477e..000000000
--- a/vendor/github.com/dsoprea/go-exif/v2/utility.go
+++ /dev/null
@@ -1,233 +0,0 @@
-package exif
-
-import (
- "fmt"
- "math"
- "reflect"
- "strconv"
- "strings"
- "time"
-
- "github.com/dsoprea/go-logging"
-
- "github.com/dsoprea/go-exif/v2/common"
- "github.com/dsoprea/go-exif/v2/undefined"
-)
-
-var (
- utilityLogger = log.NewLogger("exif.utility")
-)
-
-var (
- timeType = reflect.TypeOf(time.Time{})
-)
-
-// ParseExifFullTimestamp parses dates like "2018:11:30 13:01:49" into a UTC
-// `time.Time` struct.
-func ParseExifFullTimestamp(fullTimestampPhrase string) (timestamp time.Time, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- parts := strings.Split(fullTimestampPhrase, " ")
- datestampValue, timestampValue := parts[0], parts[1]
-
- // Normalize the separators.
- datestampValue = strings.ReplaceAll(datestampValue, "-", ":")
- timestampValue = strings.ReplaceAll(timestampValue, "-", ":")
-
- dateParts := strings.Split(datestampValue, ":")
-
- year, err := strconv.ParseUint(dateParts[0], 10, 16)
- if err != nil {
- log.Panicf("could not parse year")
- }
-
- month, err := strconv.ParseUint(dateParts[1], 10, 8)
- if err != nil {
- log.Panicf("could not parse month")
- }
-
- day, err := strconv.ParseUint(dateParts[2], 10, 8)
- if err != nil {
- log.Panicf("could not parse day")
- }
-
- timeParts := strings.Split(timestampValue, ":")
-
- hour, err := strconv.ParseUint(timeParts[0], 10, 8)
- if err != nil {
- log.Panicf("could not parse hour")
- }
-
- minute, err := strconv.ParseUint(timeParts[1], 10, 8)
- if err != nil {
- log.Panicf("could not parse minute")
- }
-
- second, err := strconv.ParseUint(timeParts[2], 10, 8)
- if err != nil {
- log.Panicf("could not parse second")
- }
-
- timestamp = time.Date(int(year), time.Month(month), int(day), int(hour), int(minute), int(second), 0, time.UTC)
- return timestamp, nil
-}
-
-// ExifFullTimestampString produces a string like "2018:11:30 13:01:49" from a
-// `time.Time` struct. It will attempt to convert to UTC first.
-func ExifFullTimestampString(t time.Time) (fullTimestampPhrase string) {
- return exifcommon.ExifFullTimestampString(t)
-}
-
-// ExifTag is one simple representation of a tag in a flat list of all of them.
-type ExifTag struct {
- // IfdPath is the fully-qualified IFD path (even though it is not named as
- // such).
- IfdPath string `json:"ifd_path"`
-
- // TagId is the tag-ID.
- TagId uint16 `json:"id"`
-
- // TagName is the tag-name. This is never empty.
- TagName string `json:"name"`
-
- // UnitCount is the recorded number of units constution of the value.
- UnitCount uint32 `json:"unit_count"`
-
- // TagTypeId is the type-ID.
- TagTypeId exifcommon.TagTypePrimitive `json:"type_id"`
-
- // TagTypeName is the type name.
- TagTypeName string `json:"type_name"`
-
- // Value is the decoded value.
- Value interface{} `json:"value"`
-
- // ValueBytes is the raw, encoded value.
- ValueBytes []byte `json:"value_bytes"`
-
- // Formatted is the human representation of the first value (tag values are
- // always an array).
- FormattedFirst string `json:"formatted_first"`
-
- // Formatted is the human representation of the complete value.
- Formatted string `json:"formatted"`
-
- // ChildIfdPath is the name of the child IFD this tag represents (if it
- // represents any). Otherwise, this is empty.
- ChildIfdPath string `json:"child_ifd_path"`
-}
-
-// String returns a string representation.
-func (et ExifTag) String() string {
- return fmt.Sprintf(
- "ExifTag<"+
- "IFD-PATH=[%s] "+
- "TAG-ID=(0x%02x) "+
- "TAG-NAME=[%s] "+
- "TAG-TYPE=[%s] "+
- "VALUE=[%v] "+
- "VALUE-BYTES=(%d) "+
- "CHILD-IFD-PATH=[%s]",
- et.IfdPath, et.TagId, et.TagName, et.TagTypeName, et.FormattedFirst,
- len(et.ValueBytes), et.ChildIfdPath)
-}
-
-// GetFlatExifData returns a simple, flat representation of all tags.
-func GetFlatExifData(exifData []byte) (exifTags []ExifTag, err error) {
- defer func() {
- if state := recover(); state != nil {
- err = log.Wrap(state.(error))
- }
- }()
-
- eh, err := ParseExifHeader(exifData)
- log.PanicIf(err)
-
- im := NewIfdMappingWithStandard()
- ti := NewTagIndex()
-
- ie := NewIfdEnumerate(im, ti, exifData, eh.ByteOrder)
-
- exifTags = make([]ExifTag, 0)
-
- visitor := func(fqIfdPath string, ifdIndex int, ite *IfdTagEntry) (err error) {
- // This encodes down to base64. Since this an example tool and we do not
- // expect to ever decode the output, we are not worried about
- // specifically base64-encoding it in order to have a measure of
- // control.
- valueBytes, err := ite.GetRawBytes()
- if err != nil {
- if err == exifundefined.ErrUnparseableValue {
- return nil
- }
-
- log.Panic(err)
- }
-
- value, err := ite.Value()
- if err != nil {
- if err == exifcommon.ErrUnhandledUndefinedTypedTag {
- value = exifundefined.UnparseableUnknownTagValuePlaceholder
- } else {
- log.Panic(err)
- }
- }
-
- et := ExifTag{
- IfdPath: fqIfdPath,
- TagId: ite.TagId(),
- TagName: ite.TagName(),
- UnitCount: ite.UnitCount(),
- TagTypeId: ite.TagType(),
- TagTypeName: ite.TagType().String(),
- Value: value,
- ValueBytes: valueBytes,
- ChildIfdPath: ite.ChildIfdPath(),
- }
-
- et.Formatted, err = ite.Format()
- log.PanicIf(err)
-
- et.FormattedFirst, err = ite.FormatFirst()
- log.PanicIf(err)
-
- exifTags = append(exifTags, et)
-
- return nil
- }
-
- _, err = ie.Scan(exifcommon.IfdStandardIfdIdentity, eh.FirstIfdOffset, visitor)
- log.PanicIf(err)
-
- return exifTags, nil
-}
-
-// GpsDegreesEquals returns true if the two `GpsDegrees` are identical.
-func GpsDegreesEquals(gi1, gi2 GpsDegrees) bool {
- if gi2.Orientation != gi1.Orientation {
- return false
- }
-
- degreesRightBound := math.Nextafter(gi1.Degrees, gi1.Degrees+1)
- minutesRightBound := math.Nextafter(gi1.Minutes, gi1.Minutes+1)
- secondsRightBound := math.Nextafter(gi1.Seconds, gi1.Seconds+1)
-
- if gi2.Degrees < gi1.Degrees || gi2.Degrees >= degreesRightBound {
- return false
- } else if gi2.Minutes < gi1.Minutes || gi2.Minutes >= minutesRightBound {
- return false
- } else if gi2.Seconds < gi1.Seconds || gi2.Seconds >= secondsRightBound {
- return false
- }
-
- return true
-}
-
-// IsTime returns true if the value is a `time.Time`.
-func IsTime(v interface{}) bool {
- return reflect.TypeOf(v) == timeType
-}