From 8f2fe15fb8b0405bb03bf8922ead205ac9a36ac4 Mon Sep 17 00:00:00 2001 From: dust-to-dust <59217631+dust-to-dust@users.noreply.github.com> Date: Fri, 8 Apr 2022 11:02:00 +0800 Subject: [PATCH] Add support for difference-aware hash calculation fix docs format --- src/PIL/Image.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/PIL/Image.py b/src/PIL/Image.py index 288d85bb8..57c2fa7cf 100644 --- a/src/PIL/Image.py +++ b/src/PIL/Image.py @@ -2695,7 +2695,8 @@ class Image: def dhash(self) -> str: """ - Calculate the dHash value of the picture. DHash value can be used to quickly determine the similarity of two pictures. + Calculate the dHash value of the picture. + DHash value can be used to quickly determine the similarity of two pictures. """ difference = self._difference(self) decimal_value = 0 @@ -2713,6 +2714,8 @@ class Image: :param image: PIL.Image / dHash(str) :param hamming_distance: + The larger the value, the greater difference between the two pictures; + otherwise, the more similar they are. :return: bool """ assert 0 <= hamming_distance <= 64 @@ -2723,8 +2726,7 @@ class Image: """ Calculate the Hamming distance between two pictures (based on dHash algorithm) :param image: PIL.Image / dHash(str) - :return: hamming distance. The larger the value, the greater the difference between the two pictures; - otherwise, the more similar they are. + :return: hamming distance. """ if isinstance(image, str): return self._hamming_distance_with_hash(image)