Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Why getbbox() returns None? #7162

@drunkwcodes

Description

@drunkwcodes

What did you do?

I tried to use the following code to chop the image edges, but the getbbox() keeps returning None.

What did you expect to happen?

I tried 9.5.0 and 8.4.0, it all returns None, but it worked and returned a tuple in older version which I can't tell.

What are your OS, Python and Pillow versions?

  • OS: Windows 10
  • Python: 3.10.11
  • Pillow: 9.5.0
from PIL import Image, ImageChops


im1 = Image.open("001-0.png")
im = im1.convert(mode="RGBA")
im1.close()
bg = Image.new(im.mode, im.size, im.getpixel((0, 0)))
diff = ImageChops.difference(im, bg)
diff = ImageChops.add(diff, diff, 2.0, -100)


bbox = diff.getbbox()

assert bbox is not None

001-0

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