Skip to content

Commit 1f35222

Browse files
authored
Merge pull request #7841 from radarhere/supportsgetmesh
2 parents 18af646 + dcbe402 commit 1f35222

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

docs/reference/ImageOps.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ only work on L and RGB images.
1414
.. autofunction:: colorize
1515
.. autofunction:: crop
1616
.. autofunction:: scale
17+
.. autoclass:: SupportsGetMesh
18+
:show-inheritance:
1719
.. autofunction:: deform
1820
.. autofunction:: equalize
1921
.. autofunction:: expand

src/PIL/ImageOps.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,15 @@ def scale(
411411
return image.resize(size, resample)
412412

413413

414-
class _SupportsGetMesh(Protocol):
414+
class SupportsGetMesh(Protocol):
415+
"""
416+
An object that supports the ``getmesh`` method, taking an image as an
417+
argument, and returning a list of tuples. Each tuple contains two tuples,
418+
the source box as a tuple of 4 integers, and a tuple of 8 integers for the
419+
final quadrilateral, in order of top left, bottom left, bottom right, top
420+
right.
421+
"""
422+
415423
def getmesh(
416424
self, image: Image.Image
417425
) -> list[
@@ -421,7 +429,7 @@ def getmesh(
421429

422430
def deform(
423431
image: Image.Image,
424-
deformer: _SupportsGetMesh,
432+
deformer: SupportsGetMesh,
425433
resample: int = Image.Resampling.BILINEAR,
426434
) -> Image.Image:
427435
"""

0 commit comments

Comments
 (0)