Merge pull request #7841 from radarhere/supportsgetmesh

This commit is contained in:
Hugo van Kemenade 2024-02-29 13:42:29 +02:00 committed by GitHub
commit 1f35222476
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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[
@ -421,7 +429,7 @@ class _SupportsGetMesh(Protocol):
def deform(
image: Image.Image,
deformer: _SupportsGetMesh,
deformer: SupportsGetMesh,
resample: int = Image.Resampling.BILINEAR,
) -> Image.Image:
"""