libphash API reference¶
Every public function, type and constant of libphash.h, grouped by topic. The usual path through the library:
- Create a context — Context.
- Load an image into it, from a file, a buffer or raw pixels — Loading images.
- Compute hashes: 64-bit hashes (aHash, dHash, pHash, wHash) or Digest hashes (mHash, BMH, Radial, ColorHash, ColorMoments); any of them by value through Algorithms as values.
- Compare two hashes with the function their kind calls for — Comparing hashes.
- Store them as text — Hashes as text.
Many images at once go through Batch hashing; tuning is in Algorithm parameters; every failure is explained in Errors; the version and the decoders a build carries are in Version and build.
The guides — which algorithm to choose, how batches and threads behave, how the library is built and verified — are the Markdown pages in the repository's docs/ directory.
Topics¶
- Errors — Every failure is a
ph_error_t; how to read one, and the details of the last failed load. - Context — The
ph_context_tthat holds one image and its configuration: create, free, and what is loaded. - Loading images — From a file, a memory buffer or raw pixels, and the settings that shape the pixels at load time: grayscale, transparency, orientation, size limit, decode scale.
- Algorithm parameters — Grayscale weights, gamma, and each algorithm's own tuning.
- 64-bit hashes — aHash, dHash, pHash and wHash, alone or several at once with
ph_compute_multi(). - Digest hashes — mHash, BMH, Radial, ColorHash and ColorMoments, returned as a
ph_digest_t. - Algorithms as values — Any algorithm through one call, selected by a
ph_algorithm_tor its name. - Comparing hashes — Distances and similarities, one per kind of digest.
- Hashes as text — Storing and reading back hashes and digests as hex strings.
- Batch hashing — Many files or buffers in one call, on a pool of worker threads.
- Version and build — The library's version, the decoders it was built with, and the ABI conventions.
Index A–Z¶
Every function, type, constant and enumerator, by its name without the ph_ or PH_ prefix.
A · B · C · D · E · F · G · H · I · L · R · S · V · W
A¶
PH_Algorithms as valuesALGO_ AHASH PH_Algorithms as valuesALGO_ BMH PH_Algorithms as valuesALGO_ COLOR_ HASH PH_Algorithms as valuesALGO_ COLOR_ MOMENTS PH_Algorithms as valuesALGO_ DHASH PH_Algorithms as valuesALGO_ FORCE_ INT32_ PH_Algorithms as valuesALGO_ MHASH PH_Algorithms as valuesALGO_ PHASH PH_Algorithms as valuesALGO_ RADIAL PH_Algorithms as valuesALGO_ WHASH PH_Algorithms as valuesALGORITHM_ COUNT ph_Algorithms as valuesalgorithm_ from_ name() ph_Algorithms as valuesalgorithm_ name() ph_Algorithms as valuesalgorithm_ t PH_Loading imagesALPHA_ BLEND_ BLACK PH_Loading imagesALPHA_ BLEND_ GREY PH_Loading imagesALPHA_ BLEND_ WHITE PH_Loading imagesALPHA_ FORCE_ INT32_ PH_Loading imagesALPHA_ IGNORE ph_Loading imagesalpha_ mode_ t
B¶
ph_Batch hashingbatch_ buffer_ item_ t ph_Batch hashingbatch_ continue_ fn PH_Batch hashingBATCH_ HASHES_ CAPACITY ph_Batch hashingbatch_ item_ t ph_Batch hashingbatch_ options_ init() ph_Batch hashingbatch_ options_ t ph_Batch hashingbatch_ progress_ fn
C¶
ph_Version and buildcan_ use_ jpeg() ph_Version and buildcan_ use_ png() ph_Version and buildcan_ use_ webp() ph_64-bit hashescompute_ ahash() ph_Digest hashescompute_ bmh() ph_Digest hashescompute_ color_ hash() ph_Digest hashescompute_ color_ moments_ hash() ph_64-bit hashescompute_ dhash() ph_Algorithms as valuescompute_ digest() ph_Digest hashescompute_ mhash() ph_64-bit hashescompute_ multi() ph_64-bit hashescompute_ phash() ph_Digest hashescompute_ radial_ hash() ph_64-bit hashescompute_ whash() ph_Contextcontext_ get_ dimensions() ph_Algorithm parameterscontext_ get_ gray_ weights() ph_Loading imagescontext_ set_ alpha_ mode() ph_Loading imagescontext_ set_ auto_ orient() ph_Algorithm parameterscontext_ set_ block_ params() ph_Loading imagescontext_ set_ decode_ scale() ph_Algorithm parameterscontext_ set_ gamma() ph_Algorithm parameterscontext_ set_ gray_ weights() ph_Loading imagescontext_ set_ load_ grayscale() ph_Loading imagescontext_ set_ max_ pixels() ph_Algorithm parameterscontext_ set_ mhash_ params() ph_Algorithm parameterscontext_ set_ phash_ params() ph_Algorithm parameterscontext_ set_ radial_ params() ph_Algorithm parameterscontext_ set_ whash_ mode() ph_Algorithm parameterscontext_ set_ whash_ remove_ max_ haar_ ll() ph_Contextcontext_ t ph_Contextcreate()
D¶
PH_Loading imagesDECODE_ SCALE_ EIGHTH PH_Loading imagesDECODE_ SCALE_ FORCE_ INT32_ PH_Loading imagesDECODE_ SCALE_ FULL PH_Loading imagesDECODE_ SCALE_ HALF PH_Loading imagesDECODE_ SCALE_ QUARTER ph_Loading imagesdecode_ scale_ t ph_Hashes as textdigest_ from_ hex() PH_Hashes as textDIGEST_ HEX_ BUFFER_ SIZE ph_Algorithms as valuesdigest_ info() PH_Digest hashesDIGEST_ KIND_ BITS PH_Digest hashesDIGEST_ KIND_ COEFFICIENTS PH_Digest hashesDIGEST_ KIND_ FORCE_ INT32_ PH_Digest hashesDIGEST_ KIND_ HISTOGRAM ph_Digest hashesdigest_ kind_ t PH_Digest hashesDIGEST_ KIND_ UNSPECIFIED PH_Digest hashesDIGEST_ KIND_ VECTOR PH_Digest hashesDIGEST_ KIND_ VECTOR16 PH_Digest hashesDIGEST_ MAX_ BYTES ph_Digest hashesdigest_ t ph_Hashes as textdigest_ to_ hex()
E¶
PH_Version and buildENUM_ FORCE_ INT32_ VALUE PH_ErrorsERR_ ALLOCATION_ FAILED PH_ErrorsERR_ CANCELLED PH_ErrorsERR_ CORRUPT_ DATA PH_ErrorsERR_ DECODER_ UNAVAILABLE PH_ErrorsERR_ EMPTY_ IMAGE PH_ErrorsERR_ FORCE_ INT32_ PH_ErrorsERR_ IMAGE_ TOO_ LARGE PH_ErrorsERR_ INVALID_ ARGUMENT PH_ErrorsERR_ IO PH_ErrorsERR_ NO_ STRUCTURE PH_ErrorsERR_ REQUIRES_ COLOR PH_ErrorsERR_ UNSUPPORTED_ FORMAT ph_Errorserror_ t
F¶
ph_Contextfree()
G¶
ph_Version and buildget_ build_ info() ph_Errorsget_ error_ string() ph_Errorsget_ last_ error_ message()
H¶
ph_Comparing hasheshamming_ distance() ph_Comparing hasheshamming_ distance_ digest() PH_64-bit hashesHASH_ AHASH ph_Batch hashinghash_ buffers() ph_Batch hashinghash_ buffers_ ex() PH_64-bit hashesHASH_ DHASH ph_Batch hashinghash_ files() ph_Batch hashinghash_ files_ ex() PH_64-bit hashesHASH_ FLAGS_ COUNT ph_64-bit hasheshash_ flags_ t PH_64-bit hashesHASH_ FORCE_ INT32_ ph_Hashes as texthash_ from_ hex() PH_64-bit hashesHASH_ PHASH ph_Hashes as texthash_ to_ hex() PH_64-bit hashesHASH_ WHASH ph_Comparing hasheshistogram_ intersection()
I¶
ph_Contextis_ loaded()
L¶
ph_Comparing hashesl2_ distance() ph_Loading imagesload_ from_ file() ph_Loading imagesload_ from_ memory() ph_Loading imagesload_ from_ pixels()
R¶
PH_Comparing hashesRADIAL_ PCC_ THRESHOLD ph_Comparing hashesradial_ similarity()
S¶
ph_Comparing hashessimilarity() ph_Comparing hashessimilarity_ digest() PH_ErrorsSUCCESS
V¶
PH_Digest hashesVECTOR16_ SCALE ph_Version and buildversion() ph_Version and buildversion_ number()
W¶
PH_Algorithm parametersWHASH_ FAST PH_Algorithm parametersWHASH_ FORCE_ INT32_ PH_Algorithm parametersWHASH_ FULL ph_Algorithm parameterswhash_ mode_ t