fix imports and lint v3

pull/71/head
Lukas Rist 2022-11-09 17:36:17 +01:00
parent e195041a4b
commit 2757c5a280
35 changed files with 134 additions and 131 deletions

View File

@ -21,6 +21,8 @@ import (
"encoding/json"
"io/ioutil"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
"github.com/jessevdk/go-flags"
@ -111,7 +113,7 @@ func main() {
entries, _, err := exif.GetFlatExifDataUniversalSearch(rawExif, nil, arguments.DoUniversalTagSearch)
if err != nil {
if arguments.SkipBlocks > 0 {
mainLogger.Warningf(context.Todo(), "Encountered an error. This might be related to the request to skip EXIF blocks.")
mainLogger.Warningf(context.TODO(), "Encountered an error. This might be related to the request to skip EXIF blocks.")
}
log.Panic(err)

View File

@ -5,11 +5,7 @@ import (
"fmt"
"strings"
"github.com/dsoprea/go-logging"
)
var (
ifdLogger = log.NewLogger("exifcommon.ifd")
log "github.com/dsoprea/go-logging"
)
var (
@ -84,7 +80,7 @@ func (im *IfdMapping) Get(parentPlacement []uint16) (childIfd *MappedIfd, err er
ptr := im.rootNode
for _, tagId := range parentPlacement {
if !descendantPtr, found := ptr.Children[tagId]; found {
if descendantPtr, found := ptr.Children[tagId]; !found {
log.Panicf("ifd child with tag-ID (%04x) not registered: [%s]", tagId, ptr.PathPhrase())
} else {
ptr = descendantPtr

View File

@ -2,6 +2,7 @@ package exifcommon
import (
"bytes"
"context"
"errors"
"math"
@ -62,14 +63,14 @@ func (p *Parser) ParseAscii(data []byte, unitCount uint32) (value string, err er
if len(data) == 0 || data[count-1] != 0 {
s := string(data[:count])
parserLogger.Warningf(context.Todo(), "ASCII not terminated with NUL as expected: [%v]", s)
parserLogger.Warningf(context.TODO(), "ASCII not terminated with NUL as expected: [%v]", s)
for i, c := range s {
if c > 127 {
// Binary
t := s[:i]
parserLogger.Warningf(context.Todo(), "ASCII also had binary characters. Truncating: [%v]->[%s]", s, t)
parserLogger.Warningf(context.TODO(), "ASCII also had binary characters. Truncating: [%v]->[%s]", s, t)
return t, nil
}

View File

@ -5,16 +5,13 @@ import (
"path"
"encoding/binary"
"io/ioutil"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)
var (
moduleRootPath = ""
testExifData []byte = nil
// EncodeDefaultByteOrder is the default byte-order for encoding operations.
EncodeDefaultByteOrder = binary.BigEndian
@ -40,7 +37,7 @@ func GetModuleRootPath() string {
tryStampFilepath := path.Join(currentPath, ".MODULE_ROOT")
_, err := os.Stat(tryStampFilepath)
if err != nil && os.IsNotExist(err) != true {
if err != nil && !os.IsNotExist(err) {
log.Panic(err)
} else if err == nil {
break
@ -66,23 +63,3 @@ func GetTestAssetsPath() string {
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
}

View File

@ -13,10 +13,6 @@ import (
log "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).

View File

@ -8,11 +8,7 @@ import (
"encoding/binary"
"github.com/dsoprea/go-logging"
)
var (
typeEncodeLogger = log.NewLogger("exif.type_encode")
log "github.com/dsoprea/go-logging"
)
// EncodedData encapsulates the compound output of an encoding operation.

View File

@ -12,6 +12,7 @@ import (
"encoding/binary"
"io/ioutil"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)
@ -244,7 +245,7 @@ func ParseExifHeader(data []byte) (eh ExifHeader, err error) {
// -> http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf
if len(data) < ExifSignatureLength {
exifLogger.Warningf(context.Todo(), "Not enough data for EXIF header: (%d)", len(data))
exifLogger.Warningf(context.TODO(), "Not enough data for EXIF header: (%d)", len(data))
return eh, ErrNoExif
}

View File

@ -9,10 +9,7 @@ go 1.12
require (
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349
github.com/go-errors/errors v1.4.2 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
github.com/jessevdk/go-flags v1.5.0
golang.org/x/net v0.0.0-20221002022538-bcab6841153b // indirect
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
gopkg.in/yaml.v2 v2.4.0
)

View File

@ -1,11 +1,17 @@
github.com/dsoprea/go-exif/v2 v2.0.0-20200321225314-640175a69fe4/go.mod h1:Lm2lMM2zx8p4a34ZemkaUV95AnMl4ZvLbCUbwOvLC2E=
github.com/dsoprea/go-exif/v3 v3.0.0-20200717053412-08f1b6708903/go.mod h1:0nsO1ce0mh5czxGeLo4+OCZ/C6Eo6ZlMWsz7rH/Gxv8=
github.com/dsoprea/go-exif/v3 v3.0.0-20210625224831-a6301f85c82b/go.mod h1:cg5SNYKHMmzxsr9X6ZeLh/nfBRHHp5PngtEPcujONtk=
github.com/dsoprea/go-exif/v3 v3.0.0-20221003160559-cf5cd88aa559/go.mod h1:rW6DMEv25U9zCtE5ukC7ttBRllXj7g7TAHl7tQrT5No=
github.com/dsoprea/go-exif/v3 v3.0.0-20221003171958-de6cb6e380a8/go.mod h1:akyZEJZ/k5bmbC9gA612ZLQkcED8enS9vuTiuAkENr0=
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696/go.mod h1:Nm/x2ZUNRW6Fe5C3LxdY1PyZY5wmDv/s5dkPJ/VB3iA=
github.com/dsoprea/go-logging v0.0.0-20200517223158-a10564966e9d/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd h1:l+vLbuxptsC6VQyQsfD7NnEC8BZuFpz45PgY+pH8YTg=
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd/go.mod h1:7I+3Pe2o/YSU88W0hWlm9S22W7XI1JFNJ86U0zPKMf8=
github.com/dsoprea/go-utility v0.0.0-20200711062821-fab8125e9bdf h1:/w4QxepU4AHh3AuO6/g8y/YIIHH5+aKP3Bj8sg5cqhU=
github.com/dsoprea/go-utility v0.0.0-20200711062821-fab8125e9bdf/go.mod h1:95+K3z2L0mqsVYd6yveIv1lmtT3tcQQ3dVakPySffW8=
github.com/dsoprea/go-utility/v2 v2.0.0-20200717064901-2fccff4aa15e/go.mod h1:uAzdkPTub5Y9yQwXe8W4m2XuP0tK4a9Q/dantD0+uaU=
github.com/dsoprea/go-utility/v2 v2.0.0-20221003142440-7a1927d49d9d/go.mod h1:LVjRU0RNUuMDqkPTxcALio0LWPFPXxxFCvVGVAwEpFc=
github.com/dsoprea/go-utility/v2 v2.0.0-20221003160719-7bc88537c05e/go.mod h1:VZ7cB0pTjm1ADBWhJUOHESu4ZYy9JN+ZPqjfiW09EPU=
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349 h1:DilThiXje0z+3UQ5YjYiSRRzVdtamFpvBQXKwMglWqw=
github.com/dsoprea/go-utility/v2 v2.0.0-20221003172846-a3e1774ef349/go.mod h1:4GC5sXji84i/p+irqghpPFZBF8tRN/Q7+700G0/DLe8=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=

View File

@ -5,6 +5,8 @@ import (
"fmt"
"time"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
"github.com/golang/geo/s2"
)

View File

@ -12,11 +12,10 @@ import (
"encoding/binary"
log "github.com/dsoprea/go-logging"
)
exifcommon "github.com/dsoprea/go-exif/v3/common"
exifundefined "github.com/dsoprea/go-exif/v3/undefined"
var (
ifdBuilderLogger = log.NewLogger("exif.ifd_builder")
log "github.com/dsoprea/go-logging"
)
var (
@ -495,7 +494,7 @@ func (ib *IfdBuilder) SetThumbnail(data []byte) (err error) {
// TODO(dustin): !! Add a test for this function.
if data == nil || len(data) == 0 {
if len(data) == 0 {
log.Panic("thumbnail is empty")
}
@ -673,7 +672,7 @@ func (ib *IfdBuilder) dumpToStrings(thisIb *IfdBuilder, prefix string, tagId uin
childPrefix := ""
if prefix == "" {
childPrefix = fmt.Sprintf("%s", thisIb.IfdIdentity().UnindexedString())
childPrefix = thisIb.IfdIdentity().UnindexedString()
} else {
childPrefix = fmt.Sprintf("%s->%s", prefix, thisIb.IfdIdentity().UnindexedString())
}
@ -1008,7 +1007,7 @@ func (ib *IfdBuilder) AddTagsFromExisting(ifd *Ifd, includeTagIds []uint16, excl
continue
}
if excludeTagIds != nil && len(excludeTagIds) > 0 {
if len(excludeTagIds) > 0 {
found := false
for _, excludedTagId := range excludeTagIds {
if excludedTagId == ite.TagId() {
@ -1021,7 +1020,7 @@ func (ib *IfdBuilder) AddTagsFromExisting(ifd *Ifd, includeTagIds []uint16, excl
}
}
if includeTagIds != nil && len(includeTagIds) > 0 {
if 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.

View File

@ -7,9 +7,9 @@ import (
"encoding/binary"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v3/common"
exifcommon "github.com/dsoprea/go-exif/v3/common"
)
const (
@ -235,7 +235,7 @@ func (ibe *IfdByteEncoder) encodeTagToBytes(ib *IfdBuilder, bt *BuilderTag, bw *
len_ := len(valueBytes)
unitCount := uint32(len_) / typeSize
if !_, found := tagsWithoutAlignment[bt.tagId]; found {
if _, found := tagsWithoutAlignment[bt.tagId]; !found {
remainder := uint32(len_) % typeSize
if remainder > 0 {

View File

@ -6,9 +6,9 @@ import (
"strings"
"testing"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v3/common"
exifcommon "github.com/dsoprea/go-exif/v3/common"
)
func Test_ByteWriter_writeAsBytes_uint8(t *testing.T) {
@ -293,17 +293,17 @@ func Test_IfdByteEncoder_encodeTagToBytes_bytes_allocated(t *testing.T) {
if childIfdBlock != nil {
t.Fatalf("no child-IFDs were expected to be allocated (2)")
} else if bytes.Compare(b.Bytes(), []byte{
} else if !bytes.Equal(b.Bytes(), []byte{
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x12, 0x34, // Tag 1
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x12, 0x39, // Tag 2
}) != 0 {
}) {
t.Fatalf("encoded tag-entry bytes not correct (2)")
} else if ida.NextOffset() != addressableOffset+uint32(10) {
t.Fatalf("allocation offset not expected (2)")
} else if bytes.Compare(ida.Bytes(), []byte{
} else if !bytes.Equal(ida.Bytes(), []byte{
0x12, 0x34, 0x56, 0x78, 0x9A,
0xbc, 0xde, 0xf0, 0x12, 0x34,
}) != 0 {
}) {
t.Fatalf("allocated data not correct (2)")
}
}

View File

@ -9,9 +9,9 @@ import (
"testing"
"time"
"github.com/dsoprea/go-exif/v3/common"
"github.com/dsoprea/go-exif/v3/undefined"
"github.com/dsoprea/go-logging"
exifcommon "github.com/dsoprea/go-exif/v3/common"
exifundefined "github.com/dsoprea/go-exif/v3/undefined"
log "github.com/dsoprea/go-logging"
)
func TestIfdBuilder_Add(t *testing.T) {
@ -2086,9 +2086,9 @@ func TestNewStandardBuilderTag__TwoUnits(t *testing.T) {
t.Fatalf("II in BuilderTag not correct")
} else if bt.tagId != 0x8833 {
t.Fatalf("tag-ID not correct")
} else if bytes.Compare(bt.value.Bytes(), []byte{
} else if !bytes.Equal(bt.value.Bytes(), []byte{
0x0, 0x0, 0x12, 0x34,
0x0, 0x0, 0x56, 0x78}) != 0 {
0x0, 0x0, 0x56, 0x78}) {
t.Fatalf("value not correct")
}
}

View File

@ -2,6 +2,7 @@ package exif
import (
"bytes"
"context"
"errors"
"fmt"
"io"
@ -11,10 +12,10 @@ import (
"encoding/binary"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v3/common"
"github.com/dsoprea/go-exif/v3/undefined"
exifcommon "github.com/dsoprea/go-exif/v3/common"
exifundefined "github.com/dsoprea/go-exif/v3/undefined"
)
var (
@ -77,7 +78,6 @@ var (
type byteParser struct {
byteOrder binary.ByteOrder
rs io.ReadSeeker
ifdOffset uint32
currentOffset uint32
}
@ -235,7 +235,7 @@ func (ie *IfdEnumerate) parseTag(ii *exifcommon.IfdIdentity, tagPosition int, bp
// 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,
ifdEnumerateLogger.Warningf(context.TODO(),
"Tag (0x%04x) in IFD [%s] at position (%d) has invalid type (0x%04x) and will be skipped.",
tagId, ii, tagPosition, int(tagType))
@ -253,7 +253,7 @@ func (ie *IfdEnumerate) parseTag(ii *exifcommon.IfdIdentity, tagPosition int, bp
it, err := ie.tagIndex.Get(ii, tagId)
if err != nil {
if log.Is(err, ErrTagNotFound) {
ifdEnumerateLogger.Warningf(context.Todo(), "Tag (0x%04x) is not known and will be skipped.", tagId)
ifdEnumerateLogger.Warningf(context.TODO(), "Tag (0x%04x) is not known and will be skipped.", tagId)
ite = &IfdTagEntry{
tagId: tagId,
@ -274,7 +274,7 @@ func (ie *IfdEnumerate) parseTag(ii *exifcommon.IfdIdentity, tagPosition int, bp
// special-case tags (e.g. thumbnails, GPS, etc..) when those tags
// suddenly have data that we no longer manipulate correctly/
// accurately.
ifdEnumerateLogger.Warningf(nil,
ifdEnumerateLogger.Warningf(context.TODO(),
"Tag (0x%04x) in IFD [%s] at position (%d) has unsupported type (0x%02x) and will be skipped.",
tagId, ii, tagPosition, int(tagType))
@ -376,7 +376,7 @@ func (ie *IfdEnumerate) tagPostParse(ite *IfdTagEntry, med *MiscellaneousExifDat
// they want to specifically manage these types of tags, they
// can use more advanced functionality to specifically -handle
// unknown tags.
utilityLogger.Warningf(nil,
utilityLogger.Warningf(context.TODO(),
"Tag with ID (0x%04x) in IFD [%s] is not recognized and "+
"will be ignored.", tagId, ii.String())
@ -385,7 +385,7 @@ func (ie *IfdEnumerate) tagPostParse(ite *IfdTagEntry, med *MiscellaneousExifDat
ite.setTagName(it.Name)
utilityLogger.Warningf(nil,
utilityLogger.Warningf(context.TODO(),
"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 "+
@ -413,7 +413,7 @@ func (ie *IfdEnumerate) tagPostParse(ite *IfdTagEntry, med *MiscellaneousExifDat
// type and caused parsing/conversion woes. So, this is a quick fix
// for those scenarios.
if !ie.tagIndex.UniversalSearch() && !it.DoesSupportType(tagType) {
ifdEnumerateLogger.Warningf(nil,
ifdEnumerateLogger.Warningf(context.TODO(),
"Skipping tag [%s] (0x%04x) [%s] with an unexpected type: %v ∉ %v",
ii.UnindexedString(), tagId, it.Name,
tagType, it.SupportedTypes)
@ -446,7 +446,7 @@ func (ie *IfdEnumerate) parseIfd(ii *exifcommon.IfdIdentity, bp *byteParser, vis
for i := 0; i < int(tagCount); i++ {
ite, err := ie.parseTag(ii, i, bp)
if err != nil {
if log.Is(err, ErrTagNotFound) == true || log.Is(err, ErrTagTypeNotValid) {
if log.Is(err, ErrTagNotFound) || log.Is(err, ErrTagTypeNotValid) {
// These tags should've been fully logged in parseTag(). The
// ITE returned is nil so we can't print anything about them, now.
continue
@ -535,7 +535,7 @@ func (ie *IfdEnumerate) parseIfd(ii *exifcommon.IfdIdentity, bp *byteParser, vis
thumbnailData, err = ie.parseThumbnail(enumeratorThumbnailOffset, enumeratorThumbnailSize)
if err != nil {
ifdEnumerateLogger.Errorf(
nil, err,
context.TODO(), err,
"We tried to bump our furthest-offset counter but there was an issue first seeking past the thumbnail.")
} else {
// In this case, the value is always an offset.
@ -560,7 +560,7 @@ func (ie *IfdEnumerate) parseIfd(ii *exifcommon.IfdIdentity, bp *byteParser, vis
_, alreadyVisited := ie.visitedIfdOffsets[nextIfdOffset]
if alreadyVisited {
ifdEnumerateLogger.Warningf(context.Todo(), "IFD at offset (0x%08x) has been linked-to more than once. There might be a cycle in the IFD chain. Not reparsing.", nextIfdOffset)
ifdEnumerateLogger.Warningf(context.TODO(), "IFD at offset (0x%08x) has been linked-to more than once. There might be a cycle in the IFD chain. Not reparsing.", nextIfdOffset)
nextIfdOffset = 0
}
@ -620,7 +620,7 @@ func (ie *IfdEnumerate) scan(iiGeneral *exifcommon.IfdIdentity, ifdOffset uint32
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)
ifdEnumerateLogger.Errorf(context.TODO(), nil, "IFD [%s] at offset (0x%04x) is unreachable. Terminating scan.", iiSibling.String(), ifdOffset)
break
}
@ -938,7 +938,7 @@ func (ifd *Ifd) printTagTree(populateValues bool, index, level int, nextLink boo
} else {
// This will just add noise to the output (byte-tags are fully
// dumped).
if ite.IsThumbnailOffset() == true || ite.IsThumbnailSize() {
if ite.IsThumbnailOffset() || ite.IsThumbnailSize() {
continue
}
@ -956,10 +956,10 @@ func (ifd *Ifd) printTagTree(populateValues bool, index, level int, nextLink boo
valuePhrase, err = ite.Format()
if err != nil {
if log.Is(err, exifcommon.ErrUnhandledUndefinedTypedTag) {
ifdEnumerateLogger.Warningf(context.Todo(), "Skipping non-standard undefined tag: [%s] (%04x)", ifd.ifdIdentity.UnindexedString(), ite.TagId())
ifdEnumerateLogger.Warningf(context.TODO(), "Skipping non-standard undefined tag: [%s] (%04x)", ifd.ifdIdentity.UnindexedString(), ite.TagId())
continue
} else if err == exifundefined.ErrUnparseableValue {
ifdEnumerateLogger.Warningf(context.Todo(), "Skipping unparseable undefined tag: [%s] (%04x) [%s]", ifd.ifdIdentity.UnindexedString(), ite.TagId(), it.Name)
ifdEnumerateLogger.Warningf(context.TODO(), "Skipping unparseable undefined tag: [%s] (%04x) [%s]", ifd.ifdIdentity.UnindexedString(), ite.TagId(), it.Name)
continue
}
@ -1112,31 +1112,31 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
log.Panicf("GPS can only be read on GPS IFD: [%s]", ifd.ifdIdentity.UnindexedString())
}
if !tags, found := ifd.entriesByTagId[TagGpsVersionId]; found {
if tags, found := ifd.entriesByTagId[TagGpsVersionId]; !found {
// We've seen this. We'll just have to default to assuming we're in a
// 2.2.0.0 format.
ifdEnumerateLogger.Warningf(context.Todo(), "No GPS version tag (0x%04x) found.", TagGpsVersionId)
ifdEnumerateLogger.Warningf(context.TODO(), "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 {
if bytes.Equal(versionBytes, acceptedGpsVersion[:]) {
hit = true
break
}
}
if hit != true {
ifdEnumerateLogger.Warningf(context.Todo(), "GPS version not supported: %v", versionBytes)
if !hit {
ifdEnumerateLogger.Warningf(context.TODO(), "GPS version not supported: %v", versionBytes)
log.Panic(ErrNoGpsTags)
}
}
tags, found := ifd.entriesByTagId[TagLatitudeId]
if !found {
ifdEnumerateLogger.Warningf(context.Todo(), "latitude not found")
ifdEnumerateLogger.Warningf(context.TODO(), "latitude not found")
log.Panic(ErrNoGpsTags)
}
@ -1146,7 +1146,7 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
// Look for whether North or South.
tags, found = ifd.entriesByTagId[TagLatitudeRefId]
if !found {
ifdEnumerateLogger.Warningf(context.Todo(), "latitude-ref not found")
ifdEnumerateLogger.Warningf(context.TODO(), "latitude-ref not found")
log.Panic(ErrNoGpsTags)
}
@ -1155,7 +1155,7 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
tags, found = ifd.entriesByTagId[TagLongitudeId]
if !found {
ifdEnumerateLogger.Warningf(context.Todo(), "longitude not found")
ifdEnumerateLogger.Warningf(context.TODO(), "longitude not found")
log.Panic(ErrNoGpsTags)
}
@ -1165,7 +1165,7 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
// Look for whether West or East.
tags, found = ifd.entriesByTagId[TagLongitudeRefId]
if !found {
ifdEnumerateLogger.Warningf(context.Todo(), "longitude-ref not found")
ifdEnumerateLogger.Warningf(context.TODO(), "longitude-ref not found")
log.Panic(ErrNoGpsTags)
}
@ -1189,7 +1189,7 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
altitudeTags, foundAltitude := ifd.entriesByTagId[TagAltitudeId]
altitudeRefTags, foundAltitudeRef := ifd.entriesByTagId[TagAltitudeRefId]
if foundAltitude == true && foundAltitudeRef {
if foundAltitude && foundAltitudeRef {
altitudePhrase, err := altitudeTags[0].Format()
log.PanicIf(err)
@ -1223,7 +1223,7 @@ func (ifd *Ifd) GpsInfo() (gi *GpsInfo, err error) {
timestampTags, foundTimestamp := ifd.entriesByTagId[TagTimestampId]
datestampTags, foundDatestamp := ifd.entriesByTagId[TagDatestampId]
if foundTimestamp == true && foundDatestamp {
if foundTimestamp && foundDatestamp {
datestampValue, err := datestampTags[0].Value()
log.PanicIf(err)

View File

@ -6,14 +6,10 @@ import (
"encoding/binary"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v3/common"
"github.com/dsoprea/go-exif/v3/undefined"
)
var (
iteLogger = log.NewLogger("exif.ifd_tag_entry")
exifcommon "github.com/dsoprea/go-exif/v3/common"
exifundefined "github.com/dsoprea/go-exif/v3/undefined"
)
// IfdTagEntry refers to a tag in the loaded EXIF block.

View File

@ -5,6 +5,8 @@ import (
"fmt"
"sync"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
"gopkg.in/yaml.v2"
)
@ -143,9 +145,9 @@ func (it *IndexedTag) GetEncodingType(value interface{}) exifcommon.TagTypePrimi
// We specifically check for the cases that we know to expect.
if supportsLong == true && supportsShort {
if supportsLong && supportsShort {
return exifcommon.TypeLong
} else if supportsRational == true && supportsSignedRational {
} else if supportsRational && supportsSignedRational {
if value == nil {
log.Panicf("GetEncodingType: require value to be given")
}
@ -299,7 +301,7 @@ func (ti *TagIndex) Get(ii *exifcommon.IfdIdentity, id uint16) (it *IndexedTag,
skipIfdPath := ii.UnindexedString()
for currentIfdPath, _ := range ti.tagsByIfd {
for currentIfdPath := range ti.tagsByIfd {
if currentIfdPath == skipIfdPath {
// Skip the primary IFD, which has already been checked.
continue
@ -307,7 +309,7 @@ func (ti *TagIndex) Get(ii *exifcommon.IfdIdentity, id uint16) (it *IndexedTag,
it, err = ti.getOne(currentIfdPath, id)
if err == nil {
tagsLogger.Warningf(nil,
tagsLogger.Warningf(context.TODO(),
"Found tag (0x%02x) in the wrong IFD: [%s] != [%s]",
id, currentIfdPath, ifdPath)
@ -442,7 +444,7 @@ func LoadStandardTags(ti *TagIndex) (err error) {
// 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 {
tagsLogger.Warningf(context.Todo(), "Type [%s] for tag [%s] being loaded is not valid and is being ignored.", tagTypeName, tagName)
tagsLogger.Warningf(context.TODO(), "Type [%s] for tag [%s] being loaded is not valid and is being ignored.", tagTypeName, tagName)
continue
}
@ -450,7 +452,7 @@ func LoadStandardTags(ti *TagIndex) (err error) {
}
if len(tagTypes) == 0 {
tagsLogger.Warningf(context.Todo(), "Tag [%s] (0x%04x) [%s] being loaded does not have any supported types and will not be registered.", ifdPath, tagId, tagName)
tagsLogger.Warningf(context.TODO(), "Tag [%s] (0x%04x) [%s] being loaded does not have any supported types and will not be registered.", ifdPath, tagId, tagName)
continue
}

View File

@ -7,9 +7,9 @@ import (
"io/ioutil"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
"github.com/dsoprea/go-exif/v3/common"
exifcommon "github.com/dsoprea/go-exif/v3/common"
)
var (
@ -149,7 +149,7 @@ func validateExifSimpleTestIb(exifData []byte, t *testing.T) {
value, err := ite.Value()
log.PanicIf(err)
if reflect.DeepEqual(value, expected[i].value) != true {
if !reflect.DeepEqual(value, expected[i].value) {
t.Fatalf("Value for entry (%d) not correct: [%v] != [%v]", i, value, expected[i].value)
}
}

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -6,6 +6,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -5,10 +5,10 @@ import (
"reflect"
"testing"
"github.com/dsoprea/go-logging"
"github.com/dsoprea/go-utility/v2/filesystem"
log "github.com/dsoprea/go-logging"
rifs "github.com/dsoprea/go-utility/v2/filesystem"
"github.com/dsoprea/go-exif/v3/common"
exifcommon "github.com/dsoprea/go-exif/v3/common"
)
func TestTag8828Oecf_String(t *testing.T) {
@ -29,7 +29,7 @@ func TestCodec8828Oecf_Encode(t *testing.T) {
Columns: 2,
Rows: 22,
ColumnNames: []string{"aa", "bb"},
Values: []exifcommon.SignedRational{{11, 22}},
Values: []exifcommon.SignedRational{{Numerator: 11, Denominator: 22}},
}
codec := Codec8828Oecf{}
@ -81,7 +81,7 @@ func TestCodec8828Oecf_Decode(t *testing.T) {
Columns: 2,
Rows: 22,
ColumnNames: []string{"aa", "bb"},
Values: []exifcommon.SignedRational{{11, 22}},
Values: []exifcommon.SignedRational{{Numerator: 11, Denominator: 22}},
}
if reflect.DeepEqual(value, expectedValue) != true {

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -6,6 +6,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -7,6 +7,8 @@ import (
"crypto/sha1"
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -2,10 +2,13 @@ package exifundefined
import (
"bytes"
"context"
"fmt"
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)
@ -114,7 +117,7 @@ func (Codec9286UserComment) Decode(valueContext *exifcommon.ValueContext) (value
encoding := valueBytes[:8]
for encodingIndex, encodingBytes := range TagUndefinedType_9286_UserComment_Encodings {
if bytes.Compare(encoding, encodingBytes) == 0 {
if bytes.Equal(encoding, encodingBytes) {
uc := Tag9286UserComment{
EncodingType: encodingIndex,
EncodingBytes: valueBytes[8:],
@ -124,7 +127,7 @@ func (Codec9286UserComment) Decode(valueContext *exifcommon.ValueContext) (value
}
}
exif9286Logger.Warningf(context.Todo(), "User-comment encoding not valid. Returning 'unknown' type (the default).")
exif9286Logger.Warningf(context.TODO(), "User-comment encoding not valid. Returning 'unknown' type (the default).")
return unknownUc, nil
}

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -6,6 +6,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -5,10 +5,9 @@ import (
"reflect"
"testing"
"github.com/dsoprea/go-logging"
"github.com/dsoprea/go-utility/v2/filesystem"
"github.com/dsoprea/go-exif/v3/common"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
rifs "github.com/dsoprea/go-utility/v2/filesystem"
)
func TestTagA20CSpatialFrequencyResponse_String(t *testing.T) {
@ -17,8 +16,8 @@ func TestTagA20CSpatialFrequencyResponse_String(t *testing.T) {
Rows: 9,
ColumnNames: []string{"column1", "column2"},
Values: []exifcommon.Rational{
{1, 2},
{3, 4},
{Numerator: 1, Denominator: 2},
{Numerator: 3, Denominator: 4},
},
}
@ -34,8 +33,8 @@ func TestCodecA20CSpatialFrequencyResponse_Encode(t *testing.T) {
Rows: 9,
ColumnNames: []string{"column1", "column2"},
Values: []exifcommon.Rational{
{1, 2},
{3, 4},
{Numerator: 1, Denominator: 2},
{Numerator: 3, Denominator: 4},
},
}
@ -68,8 +67,8 @@ func TestCodecA20CSpatialFrequencyResponse_Decode(t *testing.T) {
Rows: 9,
ColumnNames: []string{"column1", "column2"},
Values: []exifcommon.Rational{
{1, 2},
{3, 4},
{Numerator: 1, Denominator: 2},
{Numerator: 3, Denominator: 4},
},
}

View File

@ -5,6 +5,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -5,6 +5,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -6,6 +6,8 @@ import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -3,6 +3,8 @@ package exifundefined
import (
"encoding/binary"
exifcommon "github.com/dsoprea/go-exif/v3/common"
log "github.com/dsoprea/go-logging"
)

View File

@ -1,10 +1,14 @@
package exif
import (
"context"
"fmt"
"io"
"math"
exifcommon "github.com/dsoprea/go-exif/v3/common"
exifundefined "github.com/dsoprea/go-exif/v3/undefined"
log "github.com/dsoprea/go-logging"
rifs "github.com/dsoprea/go-utility/v2/filesystem"
)
@ -173,7 +177,7 @@ func getFlatExifDataUniversalSearchWithReadSeeker(rs io.ReadSeeker, so *ScanOpti
if err == exifcommon.ErrUnhandledUndefinedTypedTag {
value = exifundefined.UnparseableUnknownTagValuePlaceholder
} else if log.Is(err, exifcommon.ErrParseFail) {
utilityLogger.Warningf(nil,
utilityLogger.Warningf(context.TODO(),
"Could not parse value for tag [%s] (%04x) [%s].",
ite.IfdPath(), ite.TagId(), ite.TagName())