Documentation ¶
Overview ¶
Package imago Image saving & comparing tool for go based on webp.
Index ¶
- func BytesToString(b []byte) string
- func GetDHashStr(img image.Image) (string, error)
- func HammDistance(img1 string, img2 string) (int, error)
- func StringToBytes(s string) (b []byte)
- type NativeStorage
- func (sr *NativeStorage) AddImage(name string)
- func (ns *NativeStorage) GetConf() ([]byte, error)
- func (*NativeStorage) GetImgBytes(imgdir, name string) ([]byte, error)
- func (sr *NativeStorage) IsImgExsits(name string) bool
- func (sr *NativeStorage) Pick(exclude []string) string
- func (ns *NativeStorage) SaveConf(data []byte) error
- func (n *NativeStorage) SaveImg(r io.Reader, imgdir string, samediff int) (string, string)
- func (ns *NativeStorage) SaveImgBytes(b []byte, imgdir string, force bool, samediff int) (string, string)
- func (ns *NativeStorage) ScanImgs(imgdir string) error
- type RemoteStorage
- func (sr *RemoteStorage) AddImage(name string)
- func (remo *RemoteStorage) GetConf() (data []byte, err error)
- func (remo *RemoteStorage) GetImgBytes(imgdir, name string) (b []byte, e error)
- func (sr *RemoteStorage) IsImgExsits(name string) bool
- func (sr *RemoteStorage) Pick(exclude []string) string
- func (remo *RemoteStorage) SaveConf(data []byte) error
- func (remo *RemoteStorage) SaveImg(r io.Reader, imgdir string, samediff int) (string, string)
- func (remo *RemoteStorage) SaveImgBytes(b []byte, imgdir string, force bool, samediff int) (string, string)
- func (remo *RemoteStorage) ScanImgs(imgdir string) error
- type StorageInstance
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetDHashStr ¶
GetDHashStr Get image dhash encoded by go-base16384
func HammDistance ¶
HammDistance Get hamming distance between two dhash strings
func StringToBytes ¶ added in v1.1.0
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
IsImgExsits Return whether the name is in map
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
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
IsImgExsits Return whether the name is in map
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
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) }