This repository has been archived by the owner on May 16, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to tune hashing algorithm and image resolution
Closes #2 Signed-off-by: Igor Shishkin <me@teran.ru>
- Loading branch information
Showing
4 changed files
with
42 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package image | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/brett-lempereur/ish" | ||
) | ||
|
||
// HashType type to represent the list of hashers available | ||
type HashType string | ||
|
||
var ( | ||
// HashTypeAvg reflects AverageHash | ||
HashTypeAvg HashType = "avg" | ||
|
||
// HashTypeDiff reflects DiffrenceHash | ||
HashTypeDiff HashType = "diff" | ||
) | ||
|
||
func getHasher(kind HashType, res int) (ish.PerceptualHash, error) { | ||
switch kind { | ||
case HashTypeAvg: | ||
return ish.NewAverageHash(res, res), nil | ||
case HashTypeDiff: | ||
return ish.NewDifferenceHash(res, res), nil | ||
default: | ||
return nil, fmt.Errorf("Unknown hasher: %s", kind) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters