Open dkbarn opened 10 months ago
Bizarrely, both 37.5 and 38.5 are getting rounded to 38 on my system 😳
Works correct. There are different round rules. Python uses round to even. https://docs.python.org/3/library/functions.html#round
probably the line hashes.append(...) should be skipped if the bounding box is empty.
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