mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-11-10 19:56:47 +03:00
Merge pull request #7671 from radarhere/imagetransform
Added type hints to ImageTransform
This commit is contained in:
commit
24e9485e6b
|
@ -149,4 +149,5 @@ Work has begun to add type annotations to Pillow, including:
|
|||
* :py:mod:`~PIL.ImageChops`
|
||||
* :py:mod:`~PIL.ImageMode`
|
||||
* :py:mod:`~PIL.ImageSequence`
|
||||
* :py:mod:`~PIL.ImageTransform`
|
||||
* :py:mod:`~PIL.TarIO`
|
||||
|
|
|
@ -2643,7 +2643,7 @@ class Image:
|
|||
resample=Resampling.NEAREST,
|
||||
fill=1,
|
||||
fillcolor=None,
|
||||
):
|
||||
) -> Image:
|
||||
"""
|
||||
Transforms this image. This method creates a new image with the
|
||||
given size, and the same mode as the original, and copies data
|
||||
|
|
|
@ -14,17 +14,26 @@
|
|||
#
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence
|
||||
|
||||
from . import Image
|
||||
|
||||
|
||||
class Transform(Image.ImageTransformHandler):
|
||||
def __init__(self, data):
|
||||
method: Image.Transform
|
||||
|
||||
def __init__(self, data: Sequence[int]) -> None:
|
||||
self.data = data
|
||||
|
||||
def getdata(self):
|
||||
def getdata(self) -> tuple[int, Sequence[int]]:
|
||||
return self.method, self.data
|
||||
|
||||
def transform(self, size, image, **options):
|
||||
def transform(
|
||||
self,
|
||||
size: tuple[int, int],
|
||||
image: Image.Image,
|
||||
**options: dict[str, str | int | tuple[int, ...] | list[int]],
|
||||
) -> Image.Image:
|
||||
# can be overridden
|
||||
method, data = self.getdata()
|
||||
return image.transform(size, method, data, **options)
|
||||
|
|
Loading…
Reference in New Issue
Block a user