enhance(hash):包装散列算法中的错误提示。
This commit is contained in:
@@ -4,6 +4,7 @@ package phash
|
||||
import (
|
||||
"encoding/binary"
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"image"
|
||||
"os"
|
||||
|
||||
@@ -27,13 +28,13 @@ func HashHex(image image.Image) string {
|
||||
func HashFile(file string) ([]byte, error) {
|
||||
f, err := os.Open(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("未能打开指定文件,%w", err)
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
img, _, err := image.Decode(f)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
return nil, fmt.Errorf("未能解码指定图像文件,%w", err)
|
||||
}
|
||||
return Hash(img), nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user