🌐 AI搜索 & 代理 主页
Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/releasenotes/10.2.0.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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`
2 changes: 1 addition & 1 deletion src/PIL/Image.py
Original file line number Diff line number Diff line change
Expand Up @@ -2643,7 +2643,7 @@ def transform(
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
Expand Down
15 changes: 12 additions & 3 deletions src/PIL/ImageTransform.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down