# Build and types

## libphash\_version

```python
libphash_version() -> str
```

Return the version of the bundled libphash (`"2.0.3"`).

It is the first three numbers of `__version__`.

## build\_info

```python
build_info() -> str
```

Return how the bundled libphash was built.

The string lists the version, decoders, threads and SIMD: `"version=2.0.3 jpeg=libjpeg-turbo png=libpng ..."`.

## can\_decode

```python
can_decode(fmt: Literal['jpeg', 'png', 'webp']) -> bool
```

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

```python
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

```python
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

```python
StrPath = Union[str, bytes, 'os.PathLike[str]', 'os.PathLike[bytes]']
```

A file system path, as `open()` takes it.

## PixelArray

```python
PixelArray = SupportsArrayInterface | memoryview
```

Decoded 8-bit pixels of shape (h, w) or (h, w, 1|3|4): a numpy array, a memoryview.

## AlgorithmLike

```python
AlgorithmLike = Union['Algorithm', str]
```

## ChannelOrder

```python
ChannelOrder = Literal['rgb', 'bgr']
```

Order of the color channels in an array of pixels: `"bgr"` is OpenCV's.

## AlphaMode

```python
AlphaMode = Literal['grey', 'white', 'black', 'ignore']
```

## WHashMode

```python
WHashMode = Literal['fast', 'full']
```

## DecodeScale

```python
DecodeScale = Literal[1, 2, 4, 8]
```

## 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.
