Config¶
Config
dataclass
¶
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
class-attribute
instance-attribute
¶
Gamma applied before the Radial hash's projections; read by Radial only.
gray_weights
class-attribute
instance-attribute
¶
Relative R, G, B weights of the grayscale conversion.
phash_dct_size
class-attribute
instance-attribute
¶
pHash: side of the DCT grid (phash_reduction_size..32).
phash_reduction_size
class-attribute
instance-attribute
¶
pHash: side of the low-frequency block the hash is made of, 4..8 (the hash has its square in bits).
radial_projections
class-attribute
instance-attribute
¶
Radial: number of lines through the center, 40..4096.
radial_samples
class-attribute
instance-attribute
¶
Radial: points read on each line, 2..4096.
radial_sigma
class-attribute
instance-attribute
¶
Radial: Gaussian blur sigma before the projections, (0, 64/3].
bmh_block_size
class-attribute
instance-attribute
¶
BMH: side of the block grid, 2..32 (the digest has its square in bits).
mhash_level
class-attribute
instance-attribute
¶
mHash: scale exponent (>= 0).
mhash_size
class-attribute
instance-attribute
¶
mHash: normalization side, 62..4096.
whash_mode
class-attribute
instance-attribute
¶
whash_mode: WHashMode = 'fast'
wHash: "fast" (16x16, one Haar level) or "full" (ImageHash's scale).
whash_remove_max_haar_ll
class-attribute
instance-attribute
¶
wHash: zero the coarsest LL coefficient (ImageHash's remove_max_haar_ll).
grayscale
class-attribute
instance-attribute
¶
Decode to one gray channel: faster, but the color algorithms then raise RequiresColorError.
alpha_mode
class-attribute
instance-attribute
¶
alpha_mode: AlphaMode = 'grey'
How an alpha channel is resolved: blended over grey, white or black, or ignored.
auto_orient
class-attribute
instance-attribute
¶
Apply the EXIF orientation of JPEG and PNG files and buffers.
max_pixels
class-attribute
instance-attribute
¶
Largest image accepted, in pixels; 0 leaves only the library's fixed limit.
decode_scale
class-attribute
instance-attribute
¶
decode_scale: DecodeScale = 1
Decode at 1/1, ½, ¼ or ⅛ of the resolution where the decoder can (JPEG).