Skip to content
This repository has been archived by the owner on May 16, 2022. It is now read-only.

Commit

Permalink
Fix golint
Browse files Browse the repository at this point in the history
Signed-off-by: Igor Shishkin <me@teran.ru>
  • Loading branch information
teran committed Sep 11, 2019
1 parent d4d905e commit 927c386
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions image/image.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,18 @@ import (
)

var (
re_canon = regexp.MustCompile("(?i).cr(2)$")
re_sony = regexp.MustCompile("(?i).(arw|sr2)$")
reCanon = regexp.MustCompile("(?i).cr(2)$")
reSony = regexp.MustCompile("(?i).(arw|sr2)$")
)

// Image type
type Image struct {
filename string
fp *os.File
image stdimage.Image
}

// NewImage creates new Image object
func NewImage(filename string) (*Image, error) {
i := new(Image)
i.filename = filename
Expand All @@ -44,9 +46,9 @@ func (i *Image) open() error {
}
defer i.fp.Close()

if re_canon.Match([]byte(i.filename)) {
if reCanon.Match([]byte(i.filename)) {
err = i.openCanonRaw()
} else if re_sony.Match([]byte(i.filename)) {
} else if reSony.Match([]byte(i.filename)) {
err = i.openSonyRaw()
} else {
err = i.openStdImage()
Expand Down Expand Up @@ -113,6 +115,8 @@ func (i *Image) openSonyRaw() error {
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() (string, error) {
hasher := ish.NewAverageHash(1024, 1024)
dh, err := hasher.Hash(i.image)
Expand All @@ -126,6 +130,7 @@ func (i *Image) Hexdigest() (string, error) {
return hex.EncodeToString(h.Sum(nil)), nil
}

// Filename returns image's filename
func (i *Image) Filename() string {
return i.filename
}

0 comments on commit 927c386

Please sign in to comment.