From 501d24aa007441df00977bd4ac39d74a39a645ef Mon Sep 17 00:00:00 2001 From: Igor Shishkin Date: Thu, 12 Sep 2019 00:30:03 +0300 Subject: [PATCH] Remove soreil/arw dependency Signed-off-by: Igor Shishkin --- go.mod | 1 - go.sum | 18 ++++++++++++++++++ image/image.go | 42 ------------------------------------------ 3 files changed, 18 insertions(+), 43 deletions(-) create mode 100644 go.sum diff --git a/go.mod b/go.mod index 3a79ab2..0c63dd8 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,6 @@ module github.com/teran/imgsum go 1.13 require ( - github.com/soreil/arw v0.0.0-20180907190942-c71045f5319b github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b github.com/brett-lempereur/ish v0.0.0-20161214150457-bbdc45bcf55d github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..2e12605 --- /dev/null +++ b/go.sum @@ -0,0 +1,18 @@ +github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b h1:5Ci5wpOL75rYF6RQGRoqhEAU6xLJ6n/D4SckXX1yB74= +github.com/bamiaux/rez v0.0.0-20170731184118-29f4463c688b/go.mod h1:obBQGGIFbbv9KWg92Qu9UHeD94JXmHD1jovY/z6I3O8= +github.com/brett-lempereur/ish v0.0.0-20161214150457-bbdc45bcf55d h1:oCP9o9IOvgi0A1biE1EkI/m+pViqJoCQjU/bAopLpBo= +github.com/brett-lempereur/ish v0.0.0-20161214150457-bbdc45bcf55d/go.mod h1:sGi2C1jLbZM77czzwYX70vIkYV8Smll6xG93m96IZYw= +github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac/go.mod h1:P32wAyui1PQ58Oce/KYkOqQv8cVw1zAapXOl+dRFGbc= +github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82/go.mod h1:PxC8OnwL11+aosOB5+iEPoV3picfs8tUpkVd0pDo+Kg= +github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks= +github.com/gonum/lapack v0.0.0-20181123203213-e4cdc5a0bff9/go.mod h1:XA3DeT6rxh2EAE789SSiSJNqxPaC0aE9J8NTOI0Jo/A= +github.com/gonum/matrix v0.0.0-20181209220409-c518dec07be9/go.mod h1:0EXg4mc1CNP0HCqCz+K4ts155PXIlUywf0wqN+GfPZw= +github.com/gotk3/gotk3 v0.0.0-20190512183708-8365021fde1a/go.mod h1:Eew3QBwAOBTrfFFDmsDE5wZWbcagBL1NUslj1GhRveo= +github.com/nf/cr2 v0.0.0-20180623103828-4699471a17ed h1:QP63yO3XEt8tJ1DgBsNjbOyBGjy2eHy9ITK4Eisr9rg= +github.com/nf/cr2 v0.0.0-20180623103828-4699471a17ed/go.mod h1:HazDB3gS/i//QXMMRmTAV7Ni9gAi4mDNTH2HjZ5aVgU= +github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646/go.mod h1:jpp1/29i3P1S/RLdc7JQKbRpFeM1dOBd8T9ki5s+AY8= +github.com/steakknife/hamming v0.0.0-20180906055317-003c143a81c2 h1:o6NMd68tuqfQ0ZFnz2d16xzFNLWxrCvqF40InOJJHSM= +github.com/steakknife/hamming v0.0.0-20180906055317-003c143a81c2/go.mod h1:hpGUWaI9xL8pRQCTXQgocU38Qw1g0Us7n5PxxTwTCYU= +golang.org/x/image v0.0.0-20190516052701-61b8692d9a5c h1:VgWXv7ME0Tq2L5CBzVvhTMrfcKfvGs7ifTV9PBYTP3I= +golang.org/x/image v0.0.0-20190516052701-61b8692d9a5c/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= +golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/image/image.go b/image/image.go index 8058526..c56ae1c 100644 --- a/image/image.go +++ b/image/image.go @@ -1,21 +1,17 @@ package image import ( - "bytes" "crypto/sha256" "encoding/hex" stdimage "image" - "image/jpeg" "os" "regexp" "github.com/nf/cr2" - "github.com/soreil/arw" ) var ( reCanon = regexp.MustCompile("(?i).cr(2)$") - reSony = regexp.MustCompile("(?i).(arw|sr2)$") ) // Image type @@ -47,8 +43,6 @@ func (i *Image) open() error { if reCanon.Match([]byte(i.filename)) { err = i.openCanonRaw() - } else if reSony.Match([]byte(i.filename)) { - err = i.openSonyRaw() } else { err = i.openStdImage() } @@ -78,42 +72,6 @@ func (i *Image) openCanonRaw() error { return nil } -func (i *Image) openSonyRaw() error { - var jpegOffset uint32 - var jpegLength uint32 - - header, err := arw.ParseHeader(i.fp) - if err != nil { - return err - } - - meta, err := arw.ExtractMetaData(i.fp, int64(header.Offset), 0) - if err != nil { - return err - } - - for i := range meta.FIA { - switch meta.FIA[i].Tag { - case arw.JPEGInterchangeFormat: - jpegOffset = meta.FIA[i].Offset - case arw.JPEGInterchangeFormatLength: - jpegLength = meta.FIA[i].Offset - } - } - - jpg, err := arw.ExtractThumbnail(i.fp, jpegOffset, jpegLength) - if err != nil { - return err - } - - reader := bytes.NewReader(jpg) - i.image, err = jpeg.Decode(reader) - if err != nil { - return err - } - return nil -} - // Hexdigest produces image hash and returns it as string // actually the string is SHA256 from the hasher's value func (i *Image) Hexdigest(hashKind HashType, res int) (string, error) {