mirror of https://github.com/dsoprea/go-exif.git
ifd_enumerate.go: (*Ifd).PrintTagTree() no longer fails on parseable undefined values
https://github.com/dsoprea/go-exif/issues/33for/master
parent
6aea10b45f
commit
cc316fb440
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/dsoprea/go-logging"
|
||||
|
||||
"github.com/dsoprea/go-exif/v2/common"
|
||||
"github.com/dsoprea/go-exif/v2/undefined"
|
||||
)
|
||||
|
||||
var (
|
||||
|
@ -557,7 +558,17 @@ func (ifd *Ifd) printTagTree(populateValues bool, index, level int, nextLink boo
|
|||
var err error
|
||||
|
||||
valuePhrase, err = ite.Format()
|
||||
log.PanicIf(err)
|
||||
if err != nil {
|
||||
if log.Is(err, exifcommon.ErrUnhandledUndefinedTypedTag) == true {
|
||||
ifdEnumerateLogger.Warningf(nil, "Skipping non-standard undefined tag: [%s] (%04x)", ifd.IfdPath, ite.TagId())
|
||||
continue
|
||||
} else if err == exifundefined.ErrUnparseableValue {
|
||||
ifdEnumerateLogger.Warningf(nil, "Skipping unparseable undefined tag: [%s] (%04x) [%s]", ifd.IfdPath, ite.TagId(), it.Name)
|
||||
continue
|
||||
}
|
||||
|
||||
log.Panic(err)
|
||||
}
|
||||
} else {
|
||||
valuePhrase = "!UNRESOLVED"
|
||||
}
|
||||
|
|
|
@ -178,6 +178,8 @@ func (ite *IfdTagEntry) Format() (phrase string, err error) {
|
|||
if err != nil {
|
||||
if err == exifcommon.ErrUnhandledUndefinedTypedTag {
|
||||
return exifundefined.UnparseableUnknownTagValuePlaceholder, nil
|
||||
} else if err == exifundefined.ErrUnparseableValue {
|
||||
return exifundefined.UnparseableHandledTagValuePlaceholder, nil
|
||||
}
|
||||
|
||||
log.Panic(err)
|
||||
|
|
|
@ -9,10 +9,18 @@ import (
|
|||
)
|
||||
|
||||
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")
|
||||
)
|
||||
|
||||
|
@ -22,6 +30,8 @@ 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
|
||||
|
|
Loading…
Reference in New Issue