NewImageHash creates a new hash from an image reader
(r io.Reader, hashType ImageHashType)
| 36 | |
| 37 | // NewImageHash creates a new hash from an image reader |
| 38 | func NewImageHash(r io.Reader, hashType ImageHashType) (*ImageHash, error) { |
| 39 | data, err := io.ReadAll(r) |
| 40 | if err != nil { |
| 41 | return nil, fmt.Errorf("failed to read image data: %w", err) |
| 42 | } |
| 43 | |
| 44 | return NewImageHashFromBytes(data, hashType) |
| 45 | } |
| 46 | |
| 47 | // NewImageHashFromPath loads an image from a file path and calculates its hash |
| 48 | func NewImageHashFromPath(path string, hashType ImageHashType) (*ImageHash, error) { |