dhash

package module
Version: v0.0.0-...-f47ce30 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 19, 2016 License: MIT Imports: 6 Imported by: 0

README

dhash

dHash algorithm in Go

GoDoc Travis CI status

Install

go get github.com/guilhermehn/dhash

Or with gopkg:

go get gopkg.in/guilhermehn/dhash.v1

Usage

Two parameters are needed: the path to the image and the size that the image will be resized to, that will reflect into the hash size. The recommended size is 8.

Dhash("image.jpg", 8)

The image will be resized to 8x8 and the hash size will be size*2: "8899aabbccddeeff".

Example:
package main

import (
  "fmt"
  "github.com/guilhermehn/dhash"
  // or if you installed the gopkg version
  // "gopkg.in/guilhermehn/dhash.v1"
)

func main() {
  pathToImage := "path/to/image"
  detailLevel := 8

  hash, err := dhash.Dhash(pathToImage, detailLevel)

  if err != nil {
    fmt.Println("ERROR: %s", err.Error())
    return
  }

  fmt.Println(hash)
}

Dependencies

License

MIT

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dhash

func Dhash(path string, size int) (string, error)

Runs a difference hash algorithm on the image and returns a hash string and a error if there was one during the function execution.

func DhashFromReader

func DhashFromReader(file io.Reader, size int) (string, error)

Types

This section is empty.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL