mirror of
https://github.com/dsoprea/go-exif.git
synced 2025-05-31 11:41:57 +00:00
Revert "Report-card fixes"
This reverts commit eb5bd13c98801e8d10c570d3b3446248eebc32a5. Introduced some new issues, here. This is being debugged on a separate branch. Fixes #41
This commit is contained in:
parent
82fe0e20b9
commit
591504aef0
@ -155,9 +155,9 @@ func TestIfdMapping_ResolvePath__Regular(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []IfdTagIdAndIndex{
|
expected := []IfdTagIdAndIndex{
|
||||||
{Name: "IFD", TagId: 0, Index: 0},
|
IfdTagIdAndIndex{Name: "IFD", TagId: 0, Index: 0},
|
||||||
{Name: "Exif", TagId: 0x8769, Index: 0},
|
IfdTagIdAndIndex{Name: "Exif", TagId: 0x8769, Index: 0},
|
||||||
{Name: "Iop", TagId: 0xa005, Index: 0},
|
IfdTagIdAndIndex{Name: "Iop", TagId: 0xa005, Index: 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(lineage, expected) != true {
|
if reflect.DeepEqual(lineage, expected) != true {
|
||||||
@ -175,9 +175,9 @@ func TestIfdMapping_ResolvePath__WithIndices(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []IfdTagIdAndIndex{
|
expected := []IfdTagIdAndIndex{
|
||||||
{Name: "IFD", TagId: 0, Index: 0},
|
IfdTagIdAndIndex{Name: "IFD", TagId: 0, Index: 0},
|
||||||
{Name: "Exif", TagId: 0x8769, Index: 1},
|
IfdTagIdAndIndex{Name: "Exif", TagId: 0x8769, Index: 1},
|
||||||
{Name: "Iop", TagId: 0xa005, Index: 0},
|
IfdTagIdAndIndex{Name: "Iop", TagId: 0xa005, Index: 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(lineage, expected) != true {
|
if reflect.DeepEqual(lineage, expected) != true {
|
||||||
@ -201,9 +201,9 @@ func TestIfdMapping_ResolvePath__Miss(t *testing.T) {
|
|||||||
|
|
||||||
func TestIfdMapping_FqPathPhraseFromLineage(t *testing.T) {
|
func TestIfdMapping_FqPathPhraseFromLineage(t *testing.T) {
|
||||||
lineage := []IfdTagIdAndIndex{
|
lineage := []IfdTagIdAndIndex{
|
||||||
{Name: "IFD", Index: 0},
|
IfdTagIdAndIndex{Name: "IFD", Index: 0},
|
||||||
{Name: "Exif", Index: 1},
|
IfdTagIdAndIndex{Name: "Exif", Index: 1},
|
||||||
{Name: "Iop", Index: 0},
|
IfdTagIdAndIndex{Name: "Iop", Index: 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
im := NewIfdMapping()
|
im := NewIfdMapping()
|
||||||
@ -216,9 +216,9 @@ func TestIfdMapping_FqPathPhraseFromLineage(t *testing.T) {
|
|||||||
|
|
||||||
func TestIfdMapping_PathPhraseFromLineage(t *testing.T) {
|
func TestIfdMapping_PathPhraseFromLineage(t *testing.T) {
|
||||||
lineage := []IfdTagIdAndIndex{
|
lineage := []IfdTagIdAndIndex{
|
||||||
{Name: "IFD", Index: 0},
|
IfdTagIdAndIndex{Name: "IFD", Index: 0},
|
||||||
{Name: "Exif", Index: 1},
|
IfdTagIdAndIndex{Name: "Exif", Index: 1},
|
||||||
{Name: "Iop", Index: 0},
|
IfdTagIdAndIndex{Name: "Iop", Index: 0},
|
||||||
}
|
}
|
||||||
|
|
||||||
im := NewIfdMapping()
|
im := NewIfdMapping()
|
||||||
@ -234,7 +234,6 @@ func TestIfdMapping_NewIfdMappingWithStandard(t *testing.T) {
|
|||||||
imWithout := NewIfdMapping()
|
imWithout := NewIfdMapping()
|
||||||
|
|
||||||
err := LoadStandardIfds(imWithout)
|
err := LoadStandardIfds(imWithout)
|
||||||
log.PanicIf(err)
|
|
||||||
|
|
||||||
outputWith, err := imWith.DumpLineages()
|
outputWith, err := imWith.DumpLineages()
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
@ -16,7 +16,6 @@ var (
|
|||||||
type Parser struct {
|
type Parser struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseBytesknows how to parse a byte-type value.
|
|
||||||
func (p *Parser) ParseBytes(data []byte, unitCount uint32) (value []uint8, err error) {
|
func (p *Parser) ParseBytes(data []byte, unitCount uint32) (value []uint8, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if state := recover(); state != nil {
|
if state := recover(); state != nil {
|
||||||
@ -59,12 +58,12 @@ func (p *Parser) ParseAscii(data []byte, unitCount uint32) (value string, err er
|
|||||||
parserLogger.Warningf(nil, "ascii not terminated with nul as expected: [%v]", s)
|
parserLogger.Warningf(nil, "ascii not terminated with nul as expected: [%v]", s)
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
} else {
|
||||||
|
|
||||||
// Auto-strip the NUL from the end. It serves no purpose outside of
|
// Auto-strip the NUL from the end. It serves no purpose outside of
|
||||||
// encoding semantics.
|
// encoding semantics.
|
||||||
|
|
||||||
return string(data[:count-1]), nil
|
return string(data[:count-1]), nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ParseAsciiNoNul returns a string without any consideration for a trailing NUL
|
// ParseAsciiNoNul returns a string without any consideration for a trailing NUL
|
||||||
|
@ -182,7 +182,7 @@ func TestParser_ParseRationals__Single(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []Rational{
|
expected := []Rational{
|
||||||
{Numerator: 1, Denominator: 2},
|
Rational{Numerator: 1, Denominator: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -198,7 +198,7 @@ func TestParser_ParseRationals__Single(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected = []Rational{
|
expected = []Rational{
|
||||||
{Numerator: 1, Denominator: 2},
|
Rational{Numerator: 1, Denominator: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -218,8 +218,8 @@ func TestParser_ParseRationals__Multiple(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []Rational{
|
expected := []Rational{
|
||||||
{Numerator: 1, Denominator: 2},
|
Rational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
Rational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -274,7 +274,7 @@ func TestParser_ParseSignedRationals__Single(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []SignedRational{
|
expected := []SignedRational{
|
||||||
{Numerator: 1, Denominator: 2},
|
SignedRational{Numerator: 1, Denominator: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -290,7 +290,7 @@ func TestParser_ParseSignedRationals__Single(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected = []SignedRational{
|
expected = []SignedRational{
|
||||||
{Numerator: 1, Denominator: 2},
|
SignedRational{Numerator: 1, Denominator: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -310,8 +310,8 @@ func TestParser_ParseSignedRationals__Multiple(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []SignedRational{
|
expected := []SignedRational{
|
||||||
{Numerator: 1, Denominator: 2},
|
SignedRational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
SignedRational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
|
@ -17,7 +17,7 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNotEnoughData is used when there isn't enough data to accommodate what
|
// ErrNotEnoughData is used when there isn't enough data to accomodate what
|
||||||
// we're trying to parse (sizeof(type) * unit_count).
|
// we're trying to parse (sizeof(type) * unit_count).
|
||||||
ErrNotEnoughData = errors.New("not enough data for type")
|
ErrNotEnoughData = errors.New("not enough data for type")
|
||||||
|
|
||||||
|
@ -13,8 +13,6 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrNotFarValue indicates that an offset-based lookup was attempted for a
|
|
||||||
// non-offset-based (embedded) value.
|
|
||||||
ErrNotFarValue = errors.New("not a far value")
|
ErrNotFarValue = errors.New("not a far value")
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -39,7 +37,7 @@ type ValueContext struct {
|
|||||||
|
|
||||||
// TODO(dustin): We can update newValueContext() to derive `valueOffset` itself (from `rawValueOffset`).
|
// TODO(dustin): We can update newValueContext() to derive `valueOffset` itself (from `rawValueOffset`).
|
||||||
|
|
||||||
// NewValueContext returns a new ValueContext struct.
|
// newValueContext returns a new ValueContext struct.
|
||||||
func NewValueContext(ifdPath string, tagId uint16, unitCount, valueOffset uint32, rawValueOffset, addressableData []byte, tagType TagTypePrimitive, byteOrder binary.ByteOrder) *ValueContext {
|
func NewValueContext(ifdPath string, tagId uint16, unitCount, valueOffset uint32, rawValueOffset, addressableData []byte, tagType TagTypePrimitive, byteOrder binary.ByteOrder) *ValueContext {
|
||||||
return &ValueContext{
|
return &ValueContext{
|
||||||
unitCount: unitCount,
|
unitCount: unitCount,
|
||||||
@ -150,9 +148,9 @@ func (vc *ValueContext) readRawEncoded() (rawBytes []byte, err error) {
|
|||||||
if vc.isEmbedded() == true {
|
if vc.isEmbedded() == true {
|
||||||
byteLength := unitSizeRaw * vc.unitCount
|
byteLength := unitSizeRaw * vc.unitCount
|
||||||
return vc.rawValueOffset[:byteLength], nil
|
return vc.rawValueOffset[:byteLength], nil
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return vc.addressableData[vc.valueOffset : vc.valueOffset+vc.unitCount*unitSizeRaw], nil
|
return vc.addressableData[vc.valueOffset : vc.valueOffset+vc.unitCount*unitSizeRaw], nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetFarOffset returns the offset if the value is not embedded [within the
|
// GetFarOffset returns the offset if the value is not embedded [within the
|
||||||
@ -398,12 +396,14 @@ func (vc *ValueContext) Values() (values interface{}, err error) {
|
|||||||
|
|
||||||
// Never called.
|
// Never called.
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
} else {
|
||||||
|
|
||||||
log.Panicf("value of type [%s] is unparseable", vc.tagType)
|
log.Panicf("value of type [%s] is unparseable", vc.tagType)
|
||||||
|
|
||||||
// Never called.
|
// Never called.
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
return values, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
@ -621,8 +621,8 @@ func TestValueContext_ReadRationals(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []Rational{
|
expected := []Rational{
|
||||||
{Numerator: 1, Denominator: 2},
|
Rational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
Rational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -670,8 +670,8 @@ func TestValueContext_ReadSignedRationals(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []SignedRational{
|
expected := []SignedRational{
|
||||||
{Numerator: 1, Denominator: 2},
|
SignedRational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
SignedRational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -799,8 +799,8 @@ func TestValueContext_Values__Rational(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []Rational{
|
expected := []Rational{
|
||||||
{Numerator: 1, Denominator: 2},
|
Rational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
Rational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
@ -848,8 +848,8 @@ func TestValueContext_Values__SignedRational(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := []SignedRational{
|
expected := []SignedRational{
|
||||||
{Numerator: 1, Denominator: 2},
|
SignedRational{Numerator: 1, Denominator: 2},
|
||||||
{Numerator: 3, Denominator: 4},
|
SignedRational{Numerator: 3, Denominator: 4},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expected) != true {
|
if reflect.DeepEqual(value, expected) != true {
|
||||||
|
@ -23,12 +23,10 @@ type EncodedData struct {
|
|||||||
UnitCount uint32
|
UnitCount uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// ValueEncoder knows how to encode values of every type to bytes.
|
|
||||||
type ValueEncoder struct {
|
type ValueEncoder struct {
|
||||||
byteOrder binary.ByteOrder
|
byteOrder binary.ByteOrder
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewValueEncoder returns a new ValueEncoder.
|
|
||||||
func NewValueEncoder(byteOrder binary.ByteOrder) *ValueEncoder {
|
func NewValueEncoder(byteOrder binary.ByteOrder) *ValueEncoder {
|
||||||
return &ValueEncoder{
|
return &ValueEncoder{
|
||||||
byteOrder: byteOrder,
|
byteOrder: byteOrder,
|
||||||
|
@ -178,23 +178,23 @@ func TestValueEncoder_encodeRationals__Cycle(t *testing.T) {
|
|||||||
ve := NewValueEncoder(byteOrder)
|
ve := NewValueEncoder(byteOrder)
|
||||||
|
|
||||||
original := []Rational{
|
original := []Rational{
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x11,
|
Numerator: 0x11,
|
||||||
Denominator: 0x22,
|
Denominator: 0x22,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x33,
|
Numerator: 0x33,
|
||||||
Denominator: 0x44,
|
Denominator: 0x44,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x55,
|
Numerator: 0x55,
|
||||||
Denominator: 0x66,
|
Denominator: 0x66,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x77,
|
Numerator: 0x77,
|
||||||
Denominator: 0x88,
|
Denominator: 0x88,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x99,
|
Numerator: 0x99,
|
||||||
Denominator: 0x00,
|
Denominator: 0x00,
|
||||||
},
|
},
|
||||||
@ -274,23 +274,23 @@ func TestValueEncoder_encodeSignedRationals__Cycle(t *testing.T) {
|
|||||||
ve := NewValueEncoder(byteOrder)
|
ve := NewValueEncoder(byteOrder)
|
||||||
|
|
||||||
original := []SignedRational{
|
original := []SignedRational{
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x11,
|
Numerator: 0x11,
|
||||||
Denominator: 0x22,
|
Denominator: 0x22,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x33,
|
Numerator: 0x33,
|
||||||
Denominator: 0x44,
|
Denominator: 0x44,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x55,
|
Numerator: 0x55,
|
||||||
Denominator: 0x66,
|
Denominator: 0x66,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x77,
|
Numerator: 0x77,
|
||||||
Denominator: 0x88,
|
Denominator: 0x88,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x99,
|
Numerator: 0x99,
|
||||||
Denominator: 0x00,
|
Denominator: 0x00,
|
||||||
},
|
},
|
||||||
@ -436,23 +436,23 @@ func TestValueEncoder_Encode__Rational(t *testing.T) {
|
|||||||
ve := NewValueEncoder(byteOrder)
|
ve := NewValueEncoder(byteOrder)
|
||||||
|
|
||||||
original := []Rational{
|
original := []Rational{
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x11,
|
Numerator: 0x11,
|
||||||
Denominator: 0x22,
|
Denominator: 0x22,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x33,
|
Numerator: 0x33,
|
||||||
Denominator: 0x44,
|
Denominator: 0x44,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x55,
|
Numerator: 0x55,
|
||||||
Denominator: 0x66,
|
Denominator: 0x66,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x77,
|
Numerator: 0x77,
|
||||||
Denominator: 0x88,
|
Denominator: 0x88,
|
||||||
},
|
},
|
||||||
{
|
Rational{
|
||||||
Numerator: 0x99,
|
Numerator: 0x99,
|
||||||
Denominator: 0x00,
|
Denominator: 0x00,
|
||||||
},
|
},
|
||||||
@ -518,23 +518,23 @@ func TestValueEncoder_Encode__SignedRational(t *testing.T) {
|
|||||||
ve := NewValueEncoder(byteOrder)
|
ve := NewValueEncoder(byteOrder)
|
||||||
|
|
||||||
original := []SignedRational{
|
original := []SignedRational{
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x11,
|
Numerator: 0x11,
|
||||||
Denominator: 0x22,
|
Denominator: 0x22,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x33,
|
Numerator: 0x33,
|
||||||
Denominator: 0x44,
|
Denominator: 0x44,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x55,
|
Numerator: 0x55,
|
||||||
Denominator: 0x66,
|
Denominator: 0x66,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x77,
|
Numerator: 0x77,
|
||||||
Denominator: 0x88,
|
Denominator: 0x88,
|
||||||
},
|
},
|
||||||
{
|
SignedRational{
|
||||||
Numerator: 0x99,
|
Numerator: 0x99,
|
||||||
Denominator: 0x00,
|
Denominator: 0x00,
|
||||||
},
|
},
|
||||||
|
@ -5,10 +5,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
// ErrTagNotFound indicates that the tag was not found.
|
|
||||||
ErrTagNotFound = errors.New("tag not found")
|
ErrTagNotFound = errors.New("tag not found")
|
||||||
|
ErrTagNotStandard = errors.New("tag not a standard tag")
|
||||||
// ErrTagNotKnown indicates that the tag is not registered with us as a
|
|
||||||
// known tag.
|
|
||||||
ErrTagNotKnown = errors.New("tag is not known")
|
|
||||||
)
|
)
|
||||||
|
@ -35,7 +35,6 @@ var (
|
|||||||
mainLogger = log.NewLogger("main.main")
|
mainLogger = log.NewLogger("main.main")
|
||||||
)
|
)
|
||||||
|
|
||||||
// IfdEntry is a JSON model for representing a single tag.
|
|
||||||
type IfdEntry struct {
|
type IfdEntry struct {
|
||||||
IfdPath string `json:"ifd_path"`
|
IfdPath string `json:"ifd_path"`
|
||||||
FqIfdPath string `json:"fq_ifd_path"`
|
FqIfdPath string `json:"fq_ifd_path"`
|
||||||
|
@ -81,10 +81,10 @@ func TestVisit(t *testing.T) {
|
|||||||
if log.Is(err, ErrTagNotFound) {
|
if log.Is(err, ErrTagNotFound) {
|
||||||
fmt.Printf("Unknown tag: [%s] (%04x)\n", ii.String(), tagId)
|
fmt.Printf("Unknown tag: [%s] (%04x)\n", ii.String(), tagId)
|
||||||
return nil
|
return nil
|
||||||
}
|
} else {
|
||||||
|
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
valueString, err := ite.FormatFirst()
|
valueString, err := ite.FormatFirst()
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
@ -280,7 +280,7 @@ func TestCollect(t *testing.T) {
|
|||||||
|
|
||||||
actualIfdPaths := make([]string, len(lookup))
|
actualIfdPaths := make([]string, len(lookup))
|
||||||
i := 0
|
i := 0
|
||||||
for ifdPath := range lookup {
|
for ifdPath, _ := range lookup {
|
||||||
actualIfdPaths[i] = ifdPath
|
actualIfdPaths[i] = ifdPath
|
||||||
i++
|
i++
|
||||||
}
|
}
|
||||||
|
@ -72,9 +72,9 @@ func (d GpsDegrees) Decimal() float64 {
|
|||||||
|
|
||||||
if d.Orientation == 'S' || d.Orientation == 'W' {
|
if d.Orientation == 'S' || d.Orientation == 'W' {
|
||||||
return -decimal
|
return -decimal
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return decimal
|
return decimal
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Raw returns a Rational struct that can be used to *write* coordinates. In
|
// Raw returns a Rational struct that can be used to *write* coordinates. In
|
||||||
|
@ -954,7 +954,7 @@ func (ib *IfdBuilder) AddChildIb(childIb *IfdBuilder) (err error) {
|
|||||||
log.Panicf("Child IFD does not have the same byte-order: [%s] != [%s]", 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
|
// Since no standard IFDs supports occuring more than once, check that a
|
||||||
// tag of this type has not been previously added. Note that we just search
|
// tag of this type has not been previously added. Note that we just search
|
||||||
// the current IFD and *not every* IFD.
|
// the current IFD and *not every* IFD.
|
||||||
for _, bt := range childIb.tags {
|
for _, bt := range childIb.tags {
|
||||||
|
@ -1932,11 +1932,10 @@ func ExampleIfd_Thumbnail() {
|
|||||||
_, index, err := Collect(im, ti, rawExif)
|
_, index, err := Collect(im, ti, rawExif)
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
// This returns the raw bytes that you will be looking for, but there's no
|
thumbnailData, err := index.RootIfd.NextIfd.Thumbnail()
|
||||||
// use for them at this point in the example.
|
|
||||||
_, err = index.RootIfd.NextIfd.Thumbnail()
|
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
|
thumbnailData = thumbnailData
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1983,12 +1982,10 @@ func ExampleBuilderTag_SetValue() {
|
|||||||
// Encode.
|
// Encode.
|
||||||
|
|
||||||
ibe := NewIfdByteEncoder()
|
ibe := NewIfdByteEncoder()
|
||||||
|
updatedExif, err := ibe.EncodeToExif(rootIb)
|
||||||
// This returns the raw bytes that you will be looking for, but there's no
|
|
||||||
// use for them at this point in the example.
|
|
||||||
_, err = ibe.EncodeToExif(rootIb)
|
|
||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
|
updatedExif = updatedExif
|
||||||
// Output:
|
// Output:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,7 +715,7 @@ func (ifd *Ifd) FindTagWithName(tagName string) (results []*IfdTagEntry, err err
|
|||||||
|
|
||||||
it, err := ifd.tagIndex.GetWithName(ifd.ifdIdentity, tagName)
|
it, err := ifd.tagIndex.GetWithName(ifd.ifdIdentity, tagName)
|
||||||
if log.Is(err, ErrTagNotFound) == true {
|
if log.Is(err, ErrTagNotFound) == true {
|
||||||
log.Panic(ErrTagNotKnown)
|
log.Panic(ErrTagNotStandard)
|
||||||
} else if err != nil {
|
} else if err != nil {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
@ -1482,7 +1482,7 @@ func FindIfdFromRootIfd(rootIfd *Ifd, ifdPath string) (ifd *Ifd, err error) {
|
|||||||
thisIfd = thisIfd.NextIfd
|
thisIfd = thisIfd.NextIfd
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, itii := range lineage {
|
for i, itii := range lineage {
|
||||||
var hit *Ifd
|
var hit *Ifd
|
||||||
for _, childIfd := range thisIfd.Children {
|
for _, childIfd := range thisIfd.Children {
|
||||||
if childIfd.ifdIdentity.TagId() == itii.TagId {
|
if childIfd.ifdIdentity.TagId() == itii.TagId {
|
||||||
|
@ -79,7 +79,6 @@ func TestIfd_FindTagWithId_Hit(t *testing.T) {
|
|||||||
|
|
||||||
ifd := index.RootIfd
|
ifd := index.RootIfd
|
||||||
results, err := ifd.FindTagWithId(0x011b)
|
results, err := ifd.FindTagWithId(0x011b)
|
||||||
log.PanicIf(err)
|
|
||||||
|
|
||||||
if len(results) != 1 {
|
if len(results) != 1 {
|
||||||
t.Fatalf("Exactly one result was not found: (%d)", len(results))
|
t.Fatalf("Exactly one result was not found: (%d)", len(results))
|
||||||
@ -131,9 +130,7 @@ func TestIfd_FindTagWithName_Hit(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
ifd := index.RootIfd
|
ifd := index.RootIfd
|
||||||
|
|
||||||
results, err := ifd.FindTagWithName("YResolution")
|
results, err := ifd.FindTagWithName("YResolution")
|
||||||
log.PanicIf(err)
|
|
||||||
|
|
||||||
if len(results) != 1 {
|
if len(results) != 1 {
|
||||||
t.Fatalf("Exactly one result was not found: (%d)", len(results))
|
t.Fatalf("Exactly one result was not found: (%d)", len(results))
|
||||||
@ -189,7 +186,7 @@ func TestIfd_FindTagWithName_NonStandard(t *testing.T) {
|
|||||||
_, err = ifd.FindTagWithName("GeorgeNotAtHome")
|
_, err = ifd.FindTagWithName("GeorgeNotAtHome")
|
||||||
if err == nil {
|
if err == nil {
|
||||||
t.Fatalf("Expected error for not-found tag.")
|
t.Fatalf("Expected error for not-found tag.")
|
||||||
} else if log.Is(err, ErrTagNotKnown) == false {
|
} else if log.Is(err, ErrTagNotStandard) == false {
|
||||||
log.Panic(err)
|
log.Panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,106 +358,106 @@ func TestIfd_EnumerateTagsRecursively(t *testing.T) {
|
|||||||
log.PanicIf(err)
|
log.PanicIf(err)
|
||||||
|
|
||||||
expected := [][2]interface{}{
|
expected := [][2]interface{}{
|
||||||
{"IFD", 0x010f},
|
[2]interface{}{"IFD", 0x010f},
|
||||||
{"IFD", 0x0110},
|
[2]interface{}{"IFD", 0x0110},
|
||||||
{"IFD", 0x0112},
|
[2]interface{}{"IFD", 0x0112},
|
||||||
{"IFD", 0x011a},
|
[2]interface{}{"IFD", 0x011a},
|
||||||
{"IFD", 0x011b},
|
[2]interface{}{"IFD", 0x011b},
|
||||||
{"IFD", 0x0128},
|
[2]interface{}{"IFD", 0x0128},
|
||||||
{"IFD", 0x0132},
|
[2]interface{}{"IFD", 0x0132},
|
||||||
{"IFD", 0x013b},
|
[2]interface{}{"IFD", 0x013b},
|
||||||
{"IFD", 0x0213},
|
[2]interface{}{"IFD", 0x0213},
|
||||||
{"IFD", 0x8298},
|
[2]interface{}{"IFD", 0x8298},
|
||||||
{"IFD/Exif", 0x829a},
|
[2]interface{}{"IFD/Exif", 0x829a},
|
||||||
{"IFD/Exif", 0x829d},
|
[2]interface{}{"IFD/Exif", 0x829d},
|
||||||
{"IFD/Exif", 0x8822},
|
[2]interface{}{"IFD/Exif", 0x8822},
|
||||||
{"IFD/Exif", 0x8827},
|
[2]interface{}{"IFD/Exif", 0x8827},
|
||||||
{"IFD/Exif", 0x8830},
|
[2]interface{}{"IFD/Exif", 0x8830},
|
||||||
{"IFD/Exif", 0x8832},
|
[2]interface{}{"IFD/Exif", 0x8832},
|
||||||
{"IFD/Exif", 0x9000},
|
[2]interface{}{"IFD/Exif", 0x9000},
|
||||||
{"IFD/Exif", 0x9003},
|
[2]interface{}{"IFD/Exif", 0x9003},
|
||||||
{"IFD/Exif", 0x9004},
|
[2]interface{}{"IFD/Exif", 0x9004},
|
||||||
{"IFD/Exif", 0x9101},
|
[2]interface{}{"IFD/Exif", 0x9101},
|
||||||
{"IFD/Exif", 0x9201},
|
[2]interface{}{"IFD/Exif", 0x9201},
|
||||||
{"IFD/Exif", 0x9202},
|
[2]interface{}{"IFD/Exif", 0x9202},
|
||||||
{"IFD/Exif", 0x9204},
|
[2]interface{}{"IFD/Exif", 0x9204},
|
||||||
{"IFD/Exif", 0x9207},
|
[2]interface{}{"IFD/Exif", 0x9207},
|
||||||
{"IFD/Exif", 0x9209},
|
[2]interface{}{"IFD/Exif", 0x9209},
|
||||||
{"IFD/Exif", 0x920a},
|
[2]interface{}{"IFD/Exif", 0x920a},
|
||||||
{"IFD/Exif", 0x927c},
|
[2]interface{}{"IFD/Exif", 0x927c},
|
||||||
{"IFD/Exif", 0x9286},
|
[2]interface{}{"IFD/Exif", 0x9286},
|
||||||
{"IFD/Exif", 0x9290},
|
[2]interface{}{"IFD/Exif", 0x9290},
|
||||||
{"IFD/Exif", 0x9291},
|
[2]interface{}{"IFD/Exif", 0x9291},
|
||||||
{"IFD/Exif", 0x9292},
|
[2]interface{}{"IFD/Exif", 0x9292},
|
||||||
{"IFD/Exif", 0xa000},
|
[2]interface{}{"IFD/Exif", 0xa000},
|
||||||
{"IFD/Exif", 0xa001},
|
[2]interface{}{"IFD/Exif", 0xa001},
|
||||||
{"IFD/Exif", 0xa002},
|
[2]interface{}{"IFD/Exif", 0xa002},
|
||||||
{"IFD/Exif", 0xa003},
|
[2]interface{}{"IFD/Exif", 0xa003},
|
||||||
{"IFD/Exif/Iop", 0x0001},
|
[2]interface{}{"IFD/Exif/Iop", 0x0001},
|
||||||
{"IFD/Exif/Iop", 0x0002},
|
[2]interface{}{"IFD/Exif/Iop", 0x0002},
|
||||||
{"IFD/Exif", 0xa20e},
|
[2]interface{}{"IFD/Exif", 0xa20e},
|
||||||
{"IFD/Exif", 0xa20f},
|
[2]interface{}{"IFD/Exif", 0xa20f},
|
||||||
{"IFD/Exif", 0xa210},
|
[2]interface{}{"IFD/Exif", 0xa210},
|
||||||
{"IFD/Exif", 0xa401},
|
[2]interface{}{"IFD/Exif", 0xa401},
|
||||||
{"IFD/Exif", 0xa402},
|
[2]interface{}{"IFD/Exif", 0xa402},
|
||||||
{"IFD/Exif", 0xa403},
|
[2]interface{}{"IFD/Exif", 0xa403},
|
||||||
{"IFD/Exif", 0xa406},
|
[2]interface{}{"IFD/Exif", 0xa406},
|
||||||
{"IFD/Exif", 0xa430},
|
[2]interface{}{"IFD/Exif", 0xa430},
|
||||||
{"IFD/Exif", 0xa431},
|
[2]interface{}{"IFD/Exif", 0xa431},
|
||||||
{"IFD/Exif", 0xa432},
|
[2]interface{}{"IFD/Exif", 0xa432},
|
||||||
{"IFD/Exif", 0xa434},
|
[2]interface{}{"IFD/Exif", 0xa434},
|
||||||
{"IFD/Exif", 0xa435},
|
[2]interface{}{"IFD/Exif", 0xa435},
|
||||||
{"IFD/GPSInfo", 0x0000},
|
[2]interface{}{"IFD/GPSInfo", 0x0000},
|
||||||
{"IFD", 0x010f},
|
[2]interface{}{"IFD", 0x010f},
|
||||||
{"IFD", 0x0110},
|
[2]interface{}{"IFD", 0x0110},
|
||||||
{"IFD", 0x0112},
|
[2]interface{}{"IFD", 0x0112},
|
||||||
{"IFD", 0x011a},
|
[2]interface{}{"IFD", 0x011a},
|
||||||
{"IFD", 0x011b},
|
[2]interface{}{"IFD", 0x011b},
|
||||||
{"IFD", 0x0128},
|
[2]interface{}{"IFD", 0x0128},
|
||||||
{"IFD", 0x0132},
|
[2]interface{}{"IFD", 0x0132},
|
||||||
{"IFD", 0x013b},
|
[2]interface{}{"IFD", 0x013b},
|
||||||
{"IFD", 0x0213},
|
[2]interface{}{"IFD", 0x0213},
|
||||||
{"IFD", 0x8298},
|
[2]interface{}{"IFD", 0x8298},
|
||||||
{"IFD/Exif", 0x829a},
|
[2]interface{}{"IFD/Exif", 0x829a},
|
||||||
{"IFD/Exif", 0x829d},
|
[2]interface{}{"IFD/Exif", 0x829d},
|
||||||
{"IFD/Exif", 0x8822},
|
[2]interface{}{"IFD/Exif", 0x8822},
|
||||||
{"IFD/Exif", 0x8827},
|
[2]interface{}{"IFD/Exif", 0x8827},
|
||||||
{"IFD/Exif", 0x8830},
|
[2]interface{}{"IFD/Exif", 0x8830},
|
||||||
{"IFD/Exif", 0x8832},
|
[2]interface{}{"IFD/Exif", 0x8832},
|
||||||
{"IFD/Exif", 0x9000},
|
[2]interface{}{"IFD/Exif", 0x9000},
|
||||||
{"IFD/Exif", 0x9003},
|
[2]interface{}{"IFD/Exif", 0x9003},
|
||||||
{"IFD/Exif", 0x9004},
|
[2]interface{}{"IFD/Exif", 0x9004},
|
||||||
{"IFD/Exif", 0x9101},
|
[2]interface{}{"IFD/Exif", 0x9101},
|
||||||
{"IFD/Exif", 0x9201},
|
[2]interface{}{"IFD/Exif", 0x9201},
|
||||||
{"IFD/Exif", 0x9202},
|
[2]interface{}{"IFD/Exif", 0x9202},
|
||||||
{"IFD/Exif", 0x9204},
|
[2]interface{}{"IFD/Exif", 0x9204},
|
||||||
{"IFD/Exif", 0x9207},
|
[2]interface{}{"IFD/Exif", 0x9207},
|
||||||
{"IFD/Exif", 0x9209},
|
[2]interface{}{"IFD/Exif", 0x9209},
|
||||||
{"IFD/Exif", 0x920a},
|
[2]interface{}{"IFD/Exif", 0x920a},
|
||||||
{"IFD/Exif", 0x927c},
|
[2]interface{}{"IFD/Exif", 0x927c},
|
||||||
{"IFD/Exif", 0x9286},
|
[2]interface{}{"IFD/Exif", 0x9286},
|
||||||
{"IFD/Exif", 0x9290},
|
[2]interface{}{"IFD/Exif", 0x9290},
|
||||||
{"IFD/Exif", 0x9291},
|
[2]interface{}{"IFD/Exif", 0x9291},
|
||||||
{"IFD/Exif", 0x9292},
|
[2]interface{}{"IFD/Exif", 0x9292},
|
||||||
{"IFD/Exif", 0xa000},
|
[2]interface{}{"IFD/Exif", 0xa000},
|
||||||
{"IFD/Exif", 0xa001},
|
[2]interface{}{"IFD/Exif", 0xa001},
|
||||||
{"IFD/Exif", 0xa002},
|
[2]interface{}{"IFD/Exif", 0xa002},
|
||||||
{"IFD/Exif", 0xa003},
|
[2]interface{}{"IFD/Exif", 0xa003},
|
||||||
{"IFD/Exif/Iop", 0x0001},
|
[2]interface{}{"IFD/Exif/Iop", 0x0001},
|
||||||
{"IFD/Exif/Iop", 0x0002},
|
[2]interface{}{"IFD/Exif/Iop", 0x0002},
|
||||||
{"IFD/Exif", 0xa20e},
|
[2]interface{}{"IFD/Exif", 0xa20e},
|
||||||
{"IFD/Exif", 0xa20f},
|
[2]interface{}{"IFD/Exif", 0xa20f},
|
||||||
{"IFD/Exif", 0xa210},
|
[2]interface{}{"IFD/Exif", 0xa210},
|
||||||
{"IFD/Exif", 0xa401},
|
[2]interface{}{"IFD/Exif", 0xa401},
|
||||||
{"IFD/Exif", 0xa402},
|
[2]interface{}{"IFD/Exif", 0xa402},
|
||||||
{"IFD/Exif", 0xa403},
|
[2]interface{}{"IFD/Exif", 0xa403},
|
||||||
{"IFD/Exif", 0xa406},
|
[2]interface{}{"IFD/Exif", 0xa406},
|
||||||
{"IFD/Exif", 0xa430},
|
[2]interface{}{"IFD/Exif", 0xa430},
|
||||||
{"IFD/Exif", 0xa431},
|
[2]interface{}{"IFD/Exif", 0xa431},
|
||||||
{"IFD/Exif", 0xa432},
|
[2]interface{}{"IFD/Exif", 0xa432},
|
||||||
{"IFD/Exif", 0xa434},
|
[2]interface{}{"IFD/Exif", 0xa434},
|
||||||
{"IFD/Exif", 0xa435},
|
[2]interface{}{"IFD/Exif", 0xa435},
|
||||||
{"IFD/GPSInfo", 0x0000},
|
[2]interface{}{"IFD/GPSInfo", 0x0000},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(collected, expected) != true {
|
if reflect.DeepEqual(collected, expected) != true {
|
||||||
|
@ -36,7 +36,7 @@ type IfdTagEntry struct {
|
|||||||
// child IFD. Includes indices.
|
// child IFD. Includes indices.
|
||||||
childFqIfdPath string
|
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.
|
// TODO(dustin): !! IB's host the child-IBs directly in the tag, but that's not the case here. Refactor to accomodate it for a consistent experience.
|
||||||
|
|
||||||
ifdIdentity *exifcommon.IfdIdentity
|
ifdIdentity *exifcommon.IfdIdentity
|
||||||
|
|
||||||
@ -132,7 +132,7 @@ func (ite *IfdTagEntry) getValueOffset() uint32 {
|
|||||||
return ite.valueOffset
|
return ite.valueOffset
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetRawBytes renders a specific list of bytes from the value in this tag.
|
// RawBytes renders a specific list of bytes from the value in this tag.
|
||||||
func (ite *IfdTagEntry) GetRawBytes() (rawBytes []byte, err error) {
|
func (ite *IfdTagEntry) GetRawBytes() (rawBytes []byte, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if state := recover(); state != nil {
|
if state := recover(); state != nil {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// Package exif parses raw EXIF information given a block of raw EXIF data. It
|
// exif parses raw EXIF information given a block of raw EXIF data. It can also
|
||||||
// can also construct new EXIF information, and provides tools for doing so.
|
// construct new EXIF information, and provides tools for doing so. This package
|
||||||
// This package is not involved with the parsing of particular file-formats.
|
// is not involved with the parsing of particular file-formats.
|
||||||
//
|
//
|
||||||
// The EXIF data must first be extracted and then provided to us. Conversely,
|
// The EXIF data must first be extracted and then provided to us. Conversely,
|
||||||
// when constructing new EXIF data, the caller is responsible for packaging
|
// when constructing new EXIF data, the caller is responsible for packaging
|
||||||
|
@ -60,7 +60,7 @@ var (
|
|||||||
tagsWithoutAlignment = map[uint16]struct{}{
|
tagsWithoutAlignment = map[uint16]struct{}{
|
||||||
// The thumbnail offset is stored as a long, but its data is a binary
|
// The thumbnail offset is stored as a long, but its data is a binary
|
||||||
// blob (not a slice of longs).
|
// blob (not a slice of longs).
|
||||||
ThumbnailOffsetTagId: {},
|
ThumbnailOffsetTagId: struct{}{},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -111,7 +111,8 @@ func (it *IndexedTag) Is(ifdPath string, id uint16) bool {
|
|||||||
return it.Id == id && it.IfdPath == ifdPath
|
return it.Id == id && it.IfdPath == ifdPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetEncodingType returns the largest type that this tag's value can occupy.
|
// WidestSupportedType returns the largest type that this tag's value can
|
||||||
|
// occupy
|
||||||
func (it *IndexedTag) GetEncodingType(value interface{}) exifcommon.TagTypePrimitive {
|
func (it *IndexedTag) GetEncodingType(value interface{}) exifcommon.TagTypePrimitive {
|
||||||
// For convenience, we handle encoding a `time.Time` directly.
|
// For convenience, we handle encoding a `time.Time` directly.
|
||||||
if IsTime(value) == true {
|
if IsTime(value) == true {
|
||||||
@ -152,10 +153,10 @@ func (it *IndexedTag) GetEncodingType(value interface{}) exifcommon.TagTypePrimi
|
|||||||
|
|
||||||
if _, ok := value.(exifcommon.SignedRational); ok == true {
|
if _, ok := value.(exifcommon.SignedRational); ok == true {
|
||||||
return exifcommon.TypeSignedRational
|
return exifcommon.TypeSignedRational
|
||||||
}
|
} else {
|
||||||
|
|
||||||
return exifcommon.TypeRational
|
return exifcommon.TypeRational
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
log.Panicf("WidestSupportedType() case is not handled for tag [%s] (0x%04x): %v", it.IfdPath, it.Id, it.SupportedTypes)
|
log.Panicf("WidestSupportedType() case is not handled for tag [%s] (0x%04x): %v", it.IfdPath, it.Id, it.SupportedTypes)
|
||||||
return 0
|
return 0
|
||||||
|
@ -13,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
testExifData []byte
|
testExifData []byte = nil
|
||||||
)
|
)
|
||||||
|
|
||||||
func getExifSimpleTestIb() *IfdBuilder {
|
func getExifSimpleTestIb() *IfdBuilder {
|
||||||
@ -129,7 +129,7 @@ func validateExifSimpleTestIb(exifData []byte, t *testing.T) {
|
|||||||
t.Fatalf("Next-IFD pointer is non-nil.")
|
t.Fatalf("Next-IFD pointer is non-nil.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Verify the values by using the actual, original types (this is awesome).
|
// Verify the values by using the actual, orginal types (this is awesome).
|
||||||
|
|
||||||
expected := []struct {
|
expected := []struct {
|
||||||
tagId uint16
|
tagId uint16
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/dsoprea/go-exif/v2/common"
|
"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) {
|
func Encode(value EncodeableValue, byteOrder binary.ByteOrder) (encoded []byte, unitCount uint32, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if state := recover(); state != nil {
|
if state := recover(); state != nil {
|
||||||
@ -29,7 +28,7 @@ func Encode(value EncodeableValue, byteOrder binary.ByteOrder) (encoded []byte,
|
|||||||
return encoded, unitCount, nil
|
return encoded, unitCount, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Decode constructs a value from raw encoded bytes
|
// UndefinedValue knows how to resolve the value for most unknown-type tags.
|
||||||
func Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
|
func Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error) {
|
||||||
defer func() {
|
defer func() {
|
||||||
if state := recover(); state != nil {
|
if state := recover(); state != nil {
|
||||||
|
@ -28,7 +28,7 @@ func TestCodec8828Oecf_Encode(t *testing.T) {
|
|||||||
Columns: 2,
|
Columns: 2,
|
||||||
Rows: 22,
|
Rows: 22,
|
||||||
ColumnNames: []string{"aa", "bb"},
|
ColumnNames: []string{"aa", "bb"},
|
||||||
Values: []exifcommon.SignedRational{{11, 22}},
|
Values: []exifcommon.SignedRational{exifcommon.SignedRational{11, 22}},
|
||||||
}
|
}
|
||||||
|
|
||||||
codec := Codec8828Oecf{}
|
codec := Codec8828Oecf{}
|
||||||
@ -79,7 +79,7 @@ func TestCodec8828Oecf_Decode(t *testing.T) {
|
|||||||
Columns: 2,
|
Columns: 2,
|
||||||
Rows: 22,
|
Rows: 22,
|
||||||
ColumnNames: []string{"aa", "bb"},
|
ColumnNames: []string{"aa", "bb"},
|
||||||
Values: []exifcommon.SignedRational{{11, 22}},
|
Values: []exifcommon.SignedRational{exifcommon.SignedRational{11, 22}},
|
||||||
}
|
}
|
||||||
|
|
||||||
if reflect.DeepEqual(value, expectedValue) != true {
|
if reflect.DeepEqual(value, expectedValue) != true {
|
||||||
|
@ -34,14 +34,14 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Configurations = map[int][]byte{
|
TagUndefinedType_9101_ComponentsConfiguration_Configurations = map[int][]byte{
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_RGB: {
|
TagUndefinedType_9101_ComponentsConfiguration_RGB: []byte{
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_R,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_R,
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_G,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_G,
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_B,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_B,
|
||||||
0,
|
0,
|
||||||
},
|
},
|
||||||
|
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_YCBCR: {
|
TagUndefinedType_9101_ComponentsConfiguration_YCBCR: []byte{
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_Y,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_Y,
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_Cb,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_Cb,
|
||||||
TagUndefinedType_9101_ComponentsConfiguration_Channel_Cr,
|
TagUndefinedType_9101_ComponentsConfiguration_Channel_Cr,
|
||||||
|
@ -31,10 +31,10 @@ var (
|
|||||||
}
|
}
|
||||||
|
|
||||||
TagUndefinedType_9286_UserComment_Encodings = map[int][]byte{
|
TagUndefinedType_9286_UserComment_Encodings = map[int][]byte{
|
||||||
TagUndefinedType_9286_UserComment_Encoding_ASCII: {'A', 'S', 'C', 'I', 'I', 0, 0, 0},
|
TagUndefinedType_9286_UserComment_Encoding_ASCII: []byte{'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_JIS: []byte{'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_UNICODE: []byte{'U', 'n', 'i', 'c', 'o', 'd', 'e', 0},
|
||||||
TagUndefinedType_9286_UserComment_Encoding_UNDEFINED: {0, 0, 0, 0, 0, 0, 0, 0},
|
TagUndefinedType_9286_UserComment_Encoding_UNDEFINED: []byte{0, 0, 0, 0, 0, 0, 0, 0},
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -16,8 +16,8 @@ func TestTagA20CSpatialFrequencyResponse_String(t *testing.T) {
|
|||||||
Rows: 9,
|
Rows: 9,
|
||||||
ColumnNames: []string{"column1", "column2"},
|
ColumnNames: []string{"column1", "column2"},
|
||||||
Values: []exifcommon.Rational{
|
Values: []exifcommon.Rational{
|
||||||
{1, 2},
|
exifcommon.Rational{1, 2},
|
||||||
{3, 4},
|
exifcommon.Rational{3, 4},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -33,8 +33,8 @@ func TestCodecA20CSpatialFrequencyResponse_Encode(t *testing.T) {
|
|||||||
Rows: 9,
|
Rows: 9,
|
||||||
ColumnNames: []string{"column1", "column2"},
|
ColumnNames: []string{"column1", "column2"},
|
||||||
Values: []exifcommon.Rational{
|
Values: []exifcommon.Rational{
|
||||||
{1, 2},
|
exifcommon.Rational{1, 2},
|
||||||
{3, 4},
|
exifcommon.Rational{3, 4},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,8 +67,8 @@ func TestCodecA20CSpatialFrequencyResponse_Decode(t *testing.T) {
|
|||||||
Rows: 9,
|
Rows: 9,
|
||||||
ColumnNames: []string{"column1", "column2"},
|
ColumnNames: []string{"column1", "column2"},
|
||||||
Values: []exifcommon.Rational{
|
Values: []exifcommon.Rational{
|
||||||
{1, 2},
|
exifcommon.Rational{1, 2},
|
||||||
{3, 4},
|
exifcommon.Rational{3, 4},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,8 +4,6 @@ import (
|
|||||||
"github.com/dsoprea/go-logging"
|
"github.com/dsoprea/go-logging"
|
||||||
)
|
)
|
||||||
|
|
||||||
// UndefinedTagHandle defines one undefined-type tag with a corresponding
|
|
||||||
// decoder.
|
|
||||||
type UndefinedTagHandle struct {
|
type UndefinedTagHandle struct {
|
||||||
IfdPath string
|
IfdPath string
|
||||||
TagId uint16
|
TagId uint16
|
||||||
|
@ -37,7 +37,7 @@ type EncodeableValue interface {
|
|||||||
String() string
|
String() string
|
||||||
}
|
}
|
||||||
|
|
||||||
// UndefinedValueDecoder knows how to decode an undefined-type tag's value from
|
// UndefinedValueEncoder knows how to decode an undefined-type tag's value from
|
||||||
// bytes.
|
// bytes.
|
||||||
type UndefinedValueDecoder interface {
|
type UndefinedValueDecoder interface {
|
||||||
Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error)
|
Decode(valueContext *exifcommon.ValueContext) (value EncodeableValue, err error)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user