Skip to content

Regression in 7.1 with Image.getbbox returning None caused by converting the file to RGBA #4849

@blayzen-w

Description

@blayzen-w

What did you do?

In version 7.1.0, after converting the file to RGBA the getbbox will return None instead of the bounding box of the difference of the two images. This has happened on every file I have tried it on so far. This was working on and below 7.0.0.

What did you expect to happen?

It should return the same result as if it wasn't converted.

What actually happened?

It returned None

What are your OS, Python and Pillow versions?

  • OS: Mac 10.14.6 and ubuntu:18.04
  • Python: 3.6.5
  • Pillow: 7.1.0 though 7.2.0

This a small reproducible test case though the python shell.

Version 7.0.0 (working)

>>> from PIL import Image, ImageChops
>>> img = Image.open('some_file.jpg')
>>> bg = Image.new(img.mode, img.size, img.getpixel((0, 0)))
>>> diff = ImageChops.difference(img, bg)
>>> diff.getbbox()
(328, 328, 3880, 3885)
>>> 
>>> img = Image.open('some_file.jpg')
>>> img = img.convert('RGBA')
>>> bg = Image.new(img.mode, img.size, img.getpixel((0, 0)))
>>> diff = ImageChops.difference(img, bg)
>>> diff.getbbox()
(328, 328, 3880, 3885)

Version 7.1.0 (broken)

>>> from PIL import Image, ImageChops
>>> img = Image.open('some_file.jpg')
>>> bg = Image.new(img.mode, img.size, img.getpixel((0, 0)))
>>> diff = ImageChops.difference(img, bg)
>>> diff.getbbox()
(328, 328, 3880, 3885)
>>> 
>>> img = Image.open('some_file.jpg')
>>> img = img.convert('RGBA')
>>> bg = Image.new(img.mode, img.size, img.getpixel((0, 0)))
>>> diff = ImageChops.difference(img, bg)
>>> diff.getbbox()
>>> 

Let me know if you need any other information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions