imago

package module
v1.1.7 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2022 License: GPL-3.0 Imports: 20 Imported by: 3

README

imago

Image saving & comparing tool for go based on webp.

Functions

func Str2bytes(s string) []byte

Fast convert

func Bytes2str(b []byte) string

Fast convert

func GetDHashStr(img image.Image) (string, error)

Get image dhash encoded by go-base16384

func HammDistance(img1 string, img2 string) (int, error)

Get hamming distance between two dhash strings

func Scanimgs(imgdir string) error

Scan all images like 编码后哈希.webp

func Pick(exclude []string) string

Pick a random image

func Saveimgbytes(b []byte, imgdir string, force bool, samediff int) (string, string)
func Saveimg(r io.Reader, imgdir string, samediff int) (string, string)

Save image into imgdir with name like 编码后哈希.webp Return value: status, dhash

func Addimage(name string)

manually add an image name into map

func Imgexsits(name string) bool

Return whether the name is in map

func Setloglevel(level log.Level)

Documentation

Overview

Package imago Image saving & comparing tool for go based on webp.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BytesToString added in v1.1.0

func BytesToString(b []byte) string

BytesToString 没有内存开销的转换

func GetDHashStr

func GetDHashStr(img image.Image) (string, error)

GetDHashStr Get image dhash encoded by go-base16384

func HammDistance

func HammDistance(img1 string, img2 string) (int, error)

HammDistance Get hamming distance between two dhash strings

func StringToBytes added in v1.1.0

func StringToBytes(s string) (b []byte)

StringToBytes 没有内存开销的转换

Types

type NativeStorage added in v1.1.0

type NativeStorage struct {
	// contains filtered or unexported fields
}

func NewNativeStorage added in v1.1.0

func NewNativeStorage() (ns *NativeStorage)

func (*NativeStorage) AddImage added in v1.1.0

func (sr *NativeStorage) AddImage(name string)

AddImage manually add an image name into map

func (*NativeStorage) GetConf added in v1.1.2

func (ns *NativeStorage) GetConf() ([]byte, error)

SaveConf Save config file into storage

func (*NativeStorage) GetImgBytes added in v1.1.0

func (*NativeStorage) GetImgBytes(imgdir, name string) ([]byte, error)

GetImgBytes Get image from apiurl with name like 编码后哈希.webp Return value: imgbytes, error

func (*NativeStorage) IsImgExsits added in v1.1.0

func (sr *NativeStorage) IsImgExsits(name string) bool

IsImgExsits Return whether the name is in map

func (*NativeStorage) Pick added in v1.1.0

func (sr *NativeStorage) Pick(exclude []string) string

Pick Pick a random image

func (*NativeStorage) SaveConf added in v1.1.2

func (ns *NativeStorage) SaveConf(data []byte) error

SaveConf Save config file into storage

func (*NativeStorage) SaveImg added in v1.1.0

func (n *NativeStorage) SaveImg(r io.Reader, imgdir string, samediff int) (string, string)

SaveImg Save image into imgdir with name like 编码后哈希.webp Return value: status, dhash

func (*NativeStorage) SaveImgBytes added in v1.1.0

func (ns *NativeStorage) SaveImgBytes(b []byte, imgdir string, force bool, samediff int) (string, string)

SaveImgBytes Save image into imgdir with name like 编码后哈希.webp Return value: status, dhash

func (*NativeStorage) ScanImgs added in v1.1.0

func (ns *NativeStorage) ScanImgs(imgdir string) error

ScanImgs Scan all images like 编码后哈希.webp

type RemoteStorage added in v1.1.0

type RemoteStorage struct {
	// contains filtered or unexported fields
}

func NewRemoteStorage added in v1.1.0

func NewRemoteStorage(apiurl string, key string) (r *RemoteStorage)

func (*RemoteStorage) AddImage added in v1.1.0

func (sr *RemoteStorage) AddImage(name string)

AddImage manually add an image name into map

func (*RemoteStorage) GetConf added in v1.1.2

func (remo *RemoteStorage) GetConf() (data []byte, err error)

SaveConf Save config file into storage

func (*RemoteStorage) GetImgBytes added in v1.1.0

func (remo *RemoteStorage) GetImgBytes(imgdir, name string) (b []byte, e error)

GetImgBytes Get image from apiurl with name like 编码后哈希.webp Return value: imgbytes, error

func (*RemoteStorage) IsImgExsits added in v1.1.0

func (sr *RemoteStorage) IsImgExsits(name string) bool

IsImgExsits Return whether the name is in map

func (*RemoteStorage) Pick added in v1.1.0

func (sr *RemoteStorage) Pick(exclude []string) string

Pick Pick a random image

func (*RemoteStorage) SaveConf added in v1.1.2

func (remo *RemoteStorage) SaveConf(data []byte) error

SaveConf Save config file into storage

func (*RemoteStorage) SaveImg added in v1.1.0

func (remo *RemoteStorage) SaveImg(r io.Reader, imgdir string, samediff int) (string, string)

SaveImg Save image into apiurl with name like 编码后哈希.webp Return value: status, dhash

func (*RemoteStorage) SaveImgBytes added in v1.1.0

func (remo *RemoteStorage) SaveImgBytes(b []byte, imgdir string, force bool, samediff int) (string, string)

SaveImgBytes Save image into apiurl with name like 编码后哈希.webp Return value: status, dhash

func (*RemoteStorage) ScanImgs added in v1.1.0

func (remo *RemoteStorage) ScanImgs(imgdir string) error

ScanImgs Scan all images like 编码后哈希.webp from apiurl

type StorageInstance added in v1.1.0

type StorageInstance interface {
	GetImgBytes(imgdir, name string) ([]byte, error)
	SaveImgBytes(b []byte, imgdir string, force bool, samediff int) (string, string)
	SaveImg(r io.Reader, imgdir string, samediff int) (string, string)
	ScanImgs(imgdir string) error
	IsImgExsits(name string) bool
	AddImage(name string)
	Pick(exclude []string) string
	SaveConf(data []byte) error
	GetConf() ([]byte, error)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL