From dcbe402f77b9a6cbdc09645912404a716e597df9 Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Thu, 29 Feb 2024 20:16:41 +1100 Subject: [PATCH] Changed SupportsGetMesh protocol to be public --- docs/reference/ImageOps.rst | 2 ++ src/PIL/ImageOps.py | 12 ++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/reference/ImageOps.rst b/docs/reference/ImageOps.rst index 47525307873..051fdcfc987 100644 --- a/docs/reference/ImageOps.rst +++ b/docs/reference/ImageOps.rst @@ -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 diff --git a/src/PIL/ImageOps.py b/src/PIL/ImageOps.py index 6218c723f85..33db8fa50c7 100644 --- a/src/PIL/ImageOps.py +++ b/src/PIL/ImageOps.py @@ -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 @@ def getmesh( def deform( image: Image.Image, - deformer: _SupportsGetMesh, + deformer: SupportsGetMesh, resample: int = Image.Resampling.BILINEAR, ) -> Image.Image: """