MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / NewImageHashFromPath

Function NewImageHashFromPath

testutil/image_hash.go:48–55  ·  view source on GitHub ↗

NewImageHashFromPath loads an image from a file path and calculates its hash

(path string, hashType ImageHashType)

Source from the content-addressed store, hash-verified

46
47// NewImageHashFromPath loads an image from a file path and calculates its hash
48func 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
58func NewImageHashFromBytes(data []byte, hashType ImageHashType) (*ImageHash, error) {

Callers 1

TestSvgSuiteMethod · 0.92

Calls 2

NewImageHashFromBytesFunction · 0.85
ErrorfMethod · 0.80

Tested by 1

TestSvgSuiteMethod · 0.74