# Config

## Config

```python
Config(gamma: float = 1.0, gray_weights: tuple[int, int, int] = (38, 75, 15), phash_dct_size: int = 32, phash_reduction_size: int = 8, radial_projections: int = 180, radial_samples: int = 128, radial_sigma: float = 3.5, bmh_block_size: int = 16, mhash_alpha: float = 2.0, mhash_level: float = 1.0, mhash_size: int = 512, whash_mode: WHashMode = 'fast', whash_remove_max_haar_ll: bool = False, grayscale: bool = False, alpha_mode: AlphaMode = 'grey', auto_orient: bool = True, max_pixels: int = 256 * 1024 * 1024, decode_scale: DecodeScale = 1)
```

How images are loaded and hashed: every setting of a libphash context.

The defaults are libphash's. A `Config` is checked when it is created, against the ranges the C library accepts, so a bad value fails here with the name of the field and not at the first hash. It is immutable; :meth:`replace` gives a modified copy. The same object configures an :class:`ImageContext`, :func:`hash` and a batch.

Hash values depend on the settings: two hashes are comparable only when computed with equal configurations (and the same libphash version).

### gamma

```python
gamma: float = 1.0
```

Gamma applied before the Radial hash's projections; read by Radial only.

### gray\_weights

```python
gray_weights: tuple[int, int, int] = (38, 75, 15)
```

Relative R, G, B weights of the grayscale conversion.

### phash\_dct\_size

```python
phash_dct_size: int = 32
```

pHash: side of the DCT grid (`phash_reduction_size`..32).

### phash\_reduction\_size

```python
phash_reduction_size: int = 8
```

pHash: side of the low-frequency block the hash is made of, 4..8 (the hash has its square in bits).

### radial\_projections

```python
radial_projections: int = 180
```

Radial: number of lines through the center, 40..4096.

### radial\_samples

```python
radial_samples: int = 128
```

Radial: points read on each line, 2..4096.

### radial\_sigma

```python
radial_sigma: float = 3.5
```

Radial: Gaussian blur sigma before the projections, (0, 64/3\].

### bmh\_block\_size

```python
bmh_block_size: int = 16
```

BMH: side of the block grid, 2..32 (the digest has its square in bits).

### mhash\_alpha

```python
mhash_alpha: float = 2.0
```

mHash: scale base (\> 1).

### mhash\_level

```python
mhash_level: float = 1.0
```

mHash: scale exponent (\>= 0).

### mhash\_size

```python
mhash_size: int = 512
```

mHash: normalization side, 62..4096.

### whash\_mode

```python
whash_mode: WHashMode = 'fast'
```

wHash: `"fast"` (16x16, one Haar level) or `"full"` (ImageHash's scale).

### whash\_remove\_max\_haar\_ll

```python
whash_remove_max_haar_ll: bool = False
```

wHash: zero the coarsest LL coefficient (ImageHash's `remove_max_haar_ll`).

### grayscale

```python
grayscale: bool = False
```

Decode to one gray channel: faster, but the color algorithms then raise RequiresColorError.

### alpha\_mode

```python
alpha_mode: AlphaMode = 'grey'
```

How an alpha channel is resolved: blended over grey, white or black, or ignored.

### auto\_orient

```python
auto_orient: bool = True
```

Apply the EXIF orientation of JPEG and PNG files and buffers.

### max\_pixels

```python
max_pixels: int = 256 * 1024 * 1024
```

Largest image accepted, in pixels; 0 leaves only the library's fixed limit.

### decode\_scale

```python
decode_scale: DecodeScale = 1
```

Decode at 1/1, ½, ¼ or ⅛ of the resolution where the decoder can (JPEG).

### replace

```python
replace(**changes: Any) -> Config
```

Return a copy with the given fields changed, checked like a new Config.
