Build and types¶
libphash_version ¶
Return the version of the bundled libphash ("2.0.2").
It is the first three numbers of __version__.
build_info ¶
Return how the bundled libphash was built.
The string lists the version, decoders, threads and SIMD:
"version=2.0.2 jpeg=libjpeg-turbo png=libpng ...".
can_decode ¶
Return whether this build has a native decoder for the format.
JPEG and PNG decode without one too (through stb_image); WebP does not.
digest_info ¶
digest_info(algorithm: AlgorithmLike, config: Config | None = None) -> tuple[int, DigestKind]
Return the size in bytes and the kind of the hashes algorithm produces.
No image is needed: the answer depends only on config, which makes it fit for
sizing a database column, say. A 64-bit hash is 8 BITS bytes.
Types¶
Source
module-attribute
¶
Source = Union[str, 'os.PathLike[str]', 'os.PathLike[bytes]', bytes, bytearray, memoryview, SupportsArrayInterface, SupportsRead]
Everything :func:libphash.hash and :meth:ImageContext.load accept: a path,
encoded bytes, a binary file object, an array of pixels or a Pillow image. bytes
are always encoded image data, never a path.
StrPath
module-attribute
¶
A file system path, as open() takes it.
PixelArray
module-attribute
¶
PixelArray = SupportsArrayInterface | memoryview
Decoded 8-bit pixels of shape (h, w) or (h, w, 1|3|4): a numpy array, a memoryview.
ChannelOrder
module-attribute
¶
Order of the color channels in an array of pixels: "bgr" is OpenCV's.
SupportsRead ¶
Bases: Protocol
A binary file object: an open file, io.BytesIO, a response body.
SupportsArrayInterface ¶
Bases: Protocol
An array exposing numpy's __array_interface__.
A numpy array is one, and so is a Pillow image.
PILImage ¶
Bases: Protocol
The part of PIL.Image.Image the binding reads.