New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getbbox() returns bounding box on all-black RGB image #5247
Comments
Wow. I even iterated over all the pixels and checked that they are The question then kinda becomes, why was this not detected in RGBA space, before the change in |
Adding in the version: from PIL import Image
print("Pillow:", Image.__version__)
image = Image.open('./weird_bbox.bmp')
print(image.getbbox()) I get the same result for 7.0.0, 7.1.0 and 8.1.0 (macOS, Python 3.6.12):
|
@hugovk Yes, this image for sure. But before upgrading I was comparing images without converting to RGB, because Anyway, after sleeping over this one more night I finally think I figured it out. Something else about the upgrade, made the resulting image look slightly different from the fixture created on I'm sorry for wasting time everyone. I was just brain-fried by the |
What did you do?
Running
getbbox()
on this all black RGB image:Context / Where is this image coming from?
I'm upgrading a project that was heavily affected by the
getbbox()
alpha channel behavior change (#4849). For example before the change we were doing something like this (the simplest example):Because when comparing some images, the diff is only in the non-alpha channels and so it broke after the
7.1.0
update.To fix this, we converted these cases to variations of this:
This works in 99% of the cases, however we have one test case where it isn't because Pillow, for reasons I can't figure out, returns this (rogue ?) bounding box on this all black diff image.
What did you expect to happen?
I expected
None
to be returned.What actually happened?
Pillow returned bounding box
(8, 7, 995, 223)
.What are your OS, Python and Pillow versions?
Linux 5.8.0-7630-generic #32~1609193707~20.10~781bb80-Ubuntu SMP Tue Jan 5 21:29:56 UTC 2
Python 3.6.12
8.1.0
Repro
The text was updated successfully, but these errors were encountered: