Documentation
¶
Index ¶
Constants ¶
const ( LumaFromRCoeff = 0.299 LumaFromGCoeff = 0.587 LumaFromBCoeff = 0.114 PdqNumJaroszXYPasses = 2 DownsampleDims = 512 MinHashableDim = 5 )
Various constants pulled from the reference implementation
Variables ¶
var (
ErrInvalidFile = errors.New("invalid input file name")
)
Functions ¶
This section is empty.
Types ¶
type HashResult ¶
type HashResult struct {
Hash string
Quality int
ImageHeightTimesWidth int
HashDuration time.Duration
}
HashResult contains the output of a PDQ hash operation
func HashFromFile ¶
func HashFromFile(filename string) (*HashResult, error)
Opens a file at the specified file and uses image.Image to decode the image. Returns the result of HashFromImage. This is a convenience wrapper around HashFromImage that handles the IO and decoding for you. Ideally, you should call HashFromImage on your own with a 512x512 or smaller image that you have resized yourself. This function is provided only to match the reference implementation.
func HashFromImage ¶
func HashFromImage(img image.Image) (*HashResult, error)
HashFromImage generates a PDQ hash from an image.Image The image should idealy be pre-resizes to 512x512 or smaller for performance reasons. SEE: https://github.com/facebook/ThreatExchange/blob/main/hashing/hashing.pdf, "More on Downsampling" Returns a HashResult containing the hash and a quality score between 0 and 100. Please reference the evaluation data for selecting a good quality score. From hashing.pdf: "Confident-match distances are up to the system designer, of course, but 30, 20, or less has been found to produce good results on evaluation data."