1
0
mirror of https://github.com/fumiama/imago.git synced 2026-06-10 11:30:28 +08:00

修正uid与save add

This commit is contained in:
fumiama
2021-08-10 18:52:37 +08:00
parent 1856c27944
commit e5efa191af
2 changed files with 6 additions and 5 deletions

View File

@@ -70,7 +70,7 @@ func Addimage(name string) {
}
// Saveimgbytes Save image into imgdir with name like 编码后哈希.webp Return value: status, dhash
func Saveimgbytes(b []byte, imgdir string, uid string, force bool, samediff int) (string, string) {
func Saveimgbytes(b []byte, imgdir string, force bool, samediff int) (string, string) {
r := bytes.NewReader(b)
img, _, err := image.Decode(r)
iswebp := false
@@ -125,14 +125,15 @@ func Saveimgbytes(b []byte, imgdir string, uid string, force bool, samediff int)
log.Debugf("[saveimg] save %d bytes.\n", c)
}
log.Debugf("[saveimg] new %s.\n", dh)
Addimage(dh)
return "\"stat\":\"success\", \"img\": \"" + url.QueryEscape(dh) + "\"", dh
}
// Saveimg Save image into imgdir with name like 编码后哈希.webp Return value: status, dhash
func Saveimg(r io.Reader, imgdir string, uid string, samediff int) (string, string) {
func Saveimg(r io.Reader, imgdir string, samediff int) (string, string) {
imgbuff := make([]byte, 1024*1024) // 1m
r.Read(imgbuff)
return Saveimgbytes(imgbuff, imgdir, uid, false, samediff)
return Saveimgbytes(imgbuff, imgdir, false, samediff)
}
// Scanimgs Scan all images like 编码后哈希.webp