Skip to content
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

Changed SupportsGetMesh protocol to be public #7841

Merged
merged 1 commit into from Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/reference/ImageOps.rst
Expand Up @@ -14,6 +14,8 @@ only work on L and RGB images.
.. autofunction:: colorize
.. autofunction:: crop
.. autofunction:: scale
.. autoclass:: SupportsGetMesh
:show-inheritance:
.. autofunction:: deform
.. autofunction:: equalize
.. autofunction:: expand
Expand Down
12 changes: 10 additions & 2 deletions src/PIL/ImageOps.py
Expand Up @@ -411,7 +411,15 @@ def scale(
return image.resize(size, resample)


class _SupportsGetMesh(Protocol):
class SupportsGetMesh(Protocol):
"""
An object that supports the ``getmesh`` method, taking an image as an
argument, and returning a list of tuples. Each tuple contains two tuples,
the source box as a tuple of 4 integers, and a tuple of 8 integers for the
final quadrilateral, in order of top left, bottom left, bottom right, top
right.
"""

def getmesh(
self, image: Image.Image
) -> list[
Expand All @@ -421,7 +429,7 @@ def getmesh(

def deform(
image: Image.Image,
deformer: _SupportsGetMesh,
deformer: SupportsGetMesh,
resample: int = Image.Resampling.BILINEAR,
) -> Image.Image:
"""
Expand Down