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

Method loadDctHash

testutil/image_hash.go:227–239  ·  view source on GitHub ↗

loadDctHash reads a DCT hash from a reader

(r io.Reader)

Source from the content-addressed store, hash-verified

225
226// loadDctHash reads a DCT hash from a reader
227func (h *ImageHash) loadDctHash(r io.Reader) error {
228 var length uint16
229 if err := binary.Read(r, binary.LittleEndian, &length); err != nil {
230 return fmt.Errorf("failed to read DCT hash length: %w", err)
231 }
232
233 h.dctHash = make([]float32, length)
234 if err := binary.Read(r, binary.LittleEndian, h.dctHash); err != nil {
235 return fmt.Errorf("failed to read DCT hash values: %w", err)
236 }
237
238 return nil
239}
240
241// dctHashDistance calculates the distance between two DCT hashes
242func (h *ImageHash) dctHashDistance(other *ImageHash) float32 {

Callers 1

LoadImageHashFunction · 0.95

Calls 2

ErrorfMethod · 0.80
ReadMethod · 0.45

Tested by

no test coverage detected