Skip to content

floodfill wraps around #4016

@snoopyjc

Description

@snoopyjc

The ImageDraw.floodfill code assumes a negative index will raise an IndexError, but python wraps that around to the last element, which is not the desired effect. This causes a floodfill that hits the left side or the top of the image to wrap around to the other side. Code:

                    try:
                        p = pixel[s, t]
                    except (ValueError, IndexError):
                        pass
                    else:

Fix:

                    try:
                        if s < 0 or t < 0:
                            raise IndexError
                        p = pixel[s, t]
                    except (ValueError, IndexError):
                        pass
                    else:

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions