NewImageHashFromPath loads an image from a file path and calculates its hash
(path string, hashType ImageHashType)
| 46 | |
| 47 | // NewImageHashFromPath loads an image from a file path and calculates its hash |
| 48 | func NewImageHashFromPath(path string, hashType ImageHashType) (*ImageHash, error) { |
| 49 | data, err := os.ReadFile(path) |
| 50 | if err != nil { |
| 51 | return nil, fmt.Errorf("failed to read image file: %w", err) |
| 52 | } |
| 53 | |
| 54 | return NewImageHashFromBytes(data, hashType) |
| 55 | } |
| 56 | |
| 57 | // NewImageHashFromBytes loads an image from a byte slice and calculates its hash |
| 58 | func NewImageHashFromBytes(data []byte, hashType ImageHashType) (*ImageHash, error) { |