Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"io/ioutil"

"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

var (
Expand Down
6 changes: 3 additions & 3 deletions exif-read-tool/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"io/ioutil"

"github.com/dsoprea/go-exif"
"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

var (
Expand Down Expand Up @@ -64,7 +64,7 @@ func main() {
os.Exit(1)
}

if printLoggingArg == true {
if printLoggingArg {
cla := log.NewConsoleLogAdapter()
log.AddAdapter("console", cla)
}
Expand Down Expand Up @@ -147,7 +147,7 @@ func main() {
_, err = exif.Visit(exif.IfdStandard, im, ti, rawExif, visitor)
log.PanicIf(err)

if printAsJsonArg == true {
if printAsJsonArg {
data, err := json.MarshalIndent(entries, "", " ")
log.PanicIf(err)

Expand Down
4 changes: 2 additions & 2 deletions exif-read-tool/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"io/ioutil"
"os/exec"

"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

var (
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestMainJson(t *testing.T) {
err = json.Unmarshal(expectedRaw, &expected)
log.PanicIf(err)

if reflect.DeepEqual(actual, expected) == false {
if !reflect.DeepEqual(actual, expected) {
t.Fatalf("Output not as expected:\nACTUAL:\n%s\nEXPECTED:\n%s", actualRaw, expectedRaw)
}
}
Expand Down
17 changes: 9 additions & 8 deletions exif.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ package exif

import (
"bytes"
"context"
"errors"
"fmt"
"os"

"encoding/binary"
"io/ioutil"

"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

const (
Expand Down Expand Up @@ -78,7 +79,7 @@ func SearchAndExtractExif(data []byte) (rawExif []byte, err error) {
if _, err := ParseExifHeader(data[i:]); err == nil {
foundAt = i
break
} else if log.Is(err, ErrNoExif) == false {
} else if !log.Is(err, ErrNoExif) {
return nil, err
}
}
Expand Down Expand Up @@ -143,32 +144,32 @@ func ParseExifHeader(data []byte) (eh ExifHeader, err error) {
// -> http://www.cipa.jp/std/documents/e/DC-008-Translation-2016-E.pdf

if len(data) < 2 {
exifLogger.Warningf(nil, "Not enough data for EXIF header (1): (%d)", len(data))
exifLogger.Warningf(context.TODO(), "Not enough data for EXIF header (1): (%d)", len(data))
return eh, ErrNoExif
}

byteOrderBytes := [2]byte{data[0], data[1]}

byteOrder, found := ByteOrderLookup[byteOrderBytes]
if found == false {
// exifLogger.Warningf(nil, "EXIF byte-order not recognized: [%v]", byteOrderBytes)
if !found {
// exifLogger.Warningf(context.Todo(), "EXIF byte-order not recognized: [%v]", byteOrderBytes)
return eh, ErrNoExif
}

if len(data) < 4 {
exifLogger.Warningf(nil, "Not enough data for EXIF header (2): (%d)", len(data))
exifLogger.Warningf(context.TODO(), "Not enough data for EXIF header (2): (%d)", len(data))
return eh, ErrNoExif
}

fixedBytes := [2]byte{data[2], data[3]}
expectedFixedBytes := ExifFixedBytesLookup[byteOrder]
if fixedBytes != expectedFixedBytes {
// exifLogger.Warningf(nil, "EXIF header fixed-bytes should be [%v] but are: [%v]", expectedFixedBytes, fixedBytes)
// exifLogger.Warningf(context.Todo(), "EXIF header fixed-bytes should be [%v] but are: [%v]", expectedFixedBytes, fixedBytes)
return eh, ErrNoExif
}

if len(data) < 2 {
exifLogger.Warningf(nil, "Not enough data for EXIF header (3): (%d)", len(data))
exifLogger.Warningf(context.TODO(), "Not enough data for EXIF header (3): (%d)", len(data))
return eh, ErrNoExif
}

Expand Down
10 changes: 5 additions & 5 deletions exif_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"encoding/binary"
"io/ioutil"

"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

func TestVisit(t *testing.T) {
Expand Down Expand Up @@ -43,7 +43,7 @@ func TestVisit(t *testing.T) {
if _, err := ParseExifHeader(data[i:]); err == nil {
foundAt = i
break
} else if log.Is(err, ErrNoExif) == false {
} else if !log.Is(err, ErrNoExif) {
log.Panic(err)
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestVisit(t *testing.T) {
"IFD-PATH=[IFD] ID=(0x0128) NAME=[ResolutionUnit] COUNT=(1) TYPE=[SHORT] VALUE=[2]",
}

if reflect.DeepEqual(tags, expected) == false {
if !reflect.DeepEqual(tags, expected) {
fmt.Printf("\n")
fmt.Printf("ACTUAL:\n")
fmt.Printf("\n")
Expand Down Expand Up @@ -194,7 +194,7 @@ func TestSearchFileAndExtractExif(t *testing.T) {
rawExif, err := SearchFileAndExtractExif(testImageFilepath)
log.PanicIf(err)

if bytes.Compare(rawExif[:len(testExifData)], testExifData) != 0 {
if !bytes.Equal(rawExif[:len(testExifData)], testExifData) {
t.Fatalf("found EXIF data not correct")
}
}
Expand All @@ -206,7 +206,7 @@ func TestSearchAndExtractExif(t *testing.T) {
rawExif, err := SearchAndExtractExif(imageData)
log.PanicIf(err)

if bytes.Compare(rawExif[:len(testExifData)], testExifData) != 0 {
if !bytes.Equal(rawExif[:len(testExifData)], testExifData) {
t.Fatalf("found EXIF data not correct")
}
}
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ module github.com/dsoprea/go-exif
go 1.13

require (
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696
github.com/go-errors/errors v1.0.1 // indirect
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 // indirect
gopkg.in/yaml.v2 v2.2.7
github.com/dsoprea/go-logging v0.0.0-20200710184922-b02d349568dd
github.com/go-errors/errors v1.4.2 // indirect
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551
golang.org/x/net v0.0.0-20221002022538-bcab6841153b // indirect
gopkg.in/yaml.v2 v2.4.0
)
29 changes: 19 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,14 +1,23 @@
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696 h1:VGFnZAcLwPpt1sHlAxml+pGLZz9A2s+K/s1YNhPC91Y=
github.com/dsoprea/go-logging v0.0.0-20190624164917-c4f10aab7696/go.mod h1:Nm/x2ZUNRW6Fe5C3LxdY1PyZY5wmDv/s5dkPJ/VB3iA=
github.com/go-errors/errors v1.0.1 h1:LUHzmkK3GUKUrL/1gfBUxAHzcev3apQlezX/+O7ma6w=
github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm6/TyX73Q=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec h1:lJwO/92dFXWeXOZdoGXgptLmNLwynMSHUmU6besqtiw=
github.com/golang/geo v0.0.0-20190916061304-5b978397cfec/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
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/go-errors/errors v1.0.2/go.mod h1:psDX2osz5VnTOnFWbDeWwS7yejl+uV3FEWEp4lssFEs=
github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA=
github.com/go-errors/errors v1.4.2/go.mod h1:sIVyrIiJhuEF+Pj9Ebtd6P/rEYROXFi3BopGUQ5a5Og=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551 h1:gtexQ/VGyN+VVFRXSFiguSNcXmS6rkKT+X7FdIrTtfo=
github.com/golang/geo v0.0.0-20210211234256-740aa86cb551/go.mod h1:QZ0nwyI2jOfgRAoBvP+ab5aRr7c9x7lhGEJrKvBwjWI=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553 h1:efeOvDhwQ29Dj3SdAV/MJf8oukgn+8D8WgaCaRMchF8=
golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
golang.org/x/net v0.0.0-20221002022538-bcab6841153b h1:6e93nYa3hNqAvLr0pD4PN1fFS+gKzp2zAXqrnTCstqU=
golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.7 h1:VUgggvou5XRW9mHwD/yXxIYSMtY0zoKQf/v226p2nyo=
gopkg.in/yaml.v2 v2.2.7/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
2 changes: 1 addition & 1 deletion gps.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func (gi *GpsInfo) S2CellId() s2.CellID {
ll := s2.LatLngFromDegrees(latitude, longitude)
cellId := s2.CellIDFromLatLng(ll)

if cellId.IsValid() == false {
if !cellId.IsValid() {
panic(ErrGpsCoordinatesNotValid)
}

Expand Down
10 changes: 3 additions & 7 deletions ifd.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"fmt"
"strings"

"github.com/dsoprea/go-logging"
log "github.com/dsoprea/go-logging"
)

const (
Expand Down Expand Up @@ -36,10 +36,6 @@ const (
IfdPathStandardGps = "IFD/GPSInfo"
)

var (
ifdLogger = log.NewLogger("exif.ifd")
)

var (
ErrChildIfdNotMapped = errors.New("no child-IFD for that tag-ID under parent")
)
Expand Down Expand Up @@ -113,7 +109,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 == false {
if descendantPtr, found := ptr.Children[tagId]; !found {
log.Panicf("ifd child with tag-ID (%04x) not registered: [%s]", tagId, ptr.PathPhrase())
} else {
ptr = descendantPtr
Expand Down Expand Up @@ -328,7 +324,7 @@ func (im *IfdMapping) Add(parentPlacement []uint16, tagId uint16, name string) (
Children: make(map[uint16]*MappedIfd),
}

if _, found := ptr.Children[tagId]; found == true {
if _, found := ptr.Children[tagId]; found {
log.Panicf("child IFD with tag-ID (%04x) already registered under IFD [%s] with tag-ID (%04x)", tagId, ptr.Name, ptr.TagId)
}

Expand Down
Loading