You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/share/venv/lib/python3.10/site-packages/imagehash/__init__.py", line 695, in crop_resistant_hash
hashes.append(hash_func(bounding_box))
File "/share/venv/lib/python3.10/site-packages/imagehash/__init__.py", line 364, in whash
image_natural_scale = 2**int(numpy.log2(min(image.size)))
OverflowError: cannot convert float infinity to integer
The OverflowError is caused by the fact that on this line of code, image.size is (150, 0). In other words, the image segmentation has produced a bounding box with a 0-pixel dimension. The state of the variables at this point are:
The attached image throws an error when run through the crop_resistant_hash function using the whash hashing algorithm.
Steps to reproduce:
Traceback:
The OverflowError is caused by the fact that on this line of code,
image.size
is(150, 0)
. In other words, the image segmentation has produced a bounding box with a 0-pixel dimension. The state of the variables at this point are:So the fact that
min_y
is 37.5 andmax_y
is 38.5, when passed intoorig_image.crop
this seems to generate a 0-pixel height image.Note that Pillow's
Image.crop
method is not documented as supporting floating-point x,y coordinates: https://pillow.readthedocs.io/en/stable/reference/Image.html#PIL.Image.Image.cropAnd we can see from the source that is calling
int(round(x))
on each coordinate: https://github.com/python-pillow/Pillow/blob/main/src/PIL/Image.py#L1234Bizarrely, both 37.5 and 38.5 are getting rounded to 38 on my system 😳
In case it matters, I'm on Ubuntu 22.04.3 with Python 3.10.12
The text was updated successfully, but these errors were encountered: