mirror of
https://github.com/python-pillow/Pillow.git
synced 2024-12-24 00:46:16 +03:00
Updated type hints
This commit is contained in:
parent
d2603b779a
commit
45cdc53bbb
|
@ -124,8 +124,8 @@ def test_fastpath_translate() -> None:
|
|||
def test_center() -> None:
|
||||
im = hopper()
|
||||
rotate(im, im.mode, 45, center=(0, 0))
|
||||
rotate(im, im.mode, 45, translate=(im.size[0] / 2, 0))
|
||||
rotate(im, im.mode, 45, center=(0, 0), translate=(im.size[0] / 2, 0))
|
||||
rotate(im, im.mode, 45, translate=(im.size[0] // 2, 0))
|
||||
rotate(im, im.mode, 45, center=(0, 0), translate=(im.size[0] // 2, 0))
|
||||
|
||||
|
||||
def test_rotate_no_fill() -> None:
|
||||
|
|
|
@ -144,10 +144,12 @@ pixel, the Python Imaging Library provides different resampling *filters*.
|
|||
.. py:currentmodule:: PIL.Image
|
||||
|
||||
.. data:: Resampling.NEAREST
|
||||
:noindex:
|
||||
|
||||
Pick one nearest pixel from the input image. Ignore all other input pixels.
|
||||
|
||||
.. data:: Resampling.BOX
|
||||
:noindex:
|
||||
|
||||
Each pixel of source image contributes to one pixel of the
|
||||
destination image with identical weights.
|
||||
|
@ -158,6 +160,7 @@ pixel, the Python Imaging Library provides different resampling *filters*.
|
|||
.. versionadded:: 3.4.0
|
||||
|
||||
.. data:: Resampling.BILINEAR
|
||||
:noindex:
|
||||
|
||||
For resize calculate the output pixel value using linear interpolation
|
||||
on all pixels that may contribute to the output value.
|
||||
|
@ -165,6 +168,7 @@ pixel, the Python Imaging Library provides different resampling *filters*.
|
|||
in the input image is used.
|
||||
|
||||
.. data:: Resampling.HAMMING
|
||||
:noindex:
|
||||
|
||||
Produces a sharper image than :data:`Resampling.BILINEAR`, doesn't have
|
||||
dislocations on local level like with :data:`Resampling.BOX`.
|
||||
|
@ -174,6 +178,7 @@ pixel, the Python Imaging Library provides different resampling *filters*.
|
|||
.. versionadded:: 3.4.0
|
||||
|
||||
.. data:: Resampling.BICUBIC
|
||||
:noindex:
|
||||
|
||||
For resize calculate the output pixel value using cubic interpolation
|
||||
on all pixels that may contribute to the output value.
|
||||
|
@ -181,6 +186,7 @@ pixel, the Python Imaging Library provides different resampling *filters*.
|
|||
in the input image is used.
|
||||
|
||||
.. data:: Resampling.LANCZOS
|
||||
:noindex:
|
||||
|
||||
Calculate the output pixel value using a high-quality Lanczos filter (a
|
||||
truncated sinc) on all pixels that may contribute to the output value.
|
||||
|
|
|
@ -424,7 +424,6 @@ See :ref:`concept-filters` for details.
|
|||
.. autoclass:: Resampling
|
||||
:members:
|
||||
:undoc-members:
|
||||
:noindex:
|
||||
|
||||
Dither modes
|
||||
^^^^^^^^^^^^
|
||||
|
|
|
@ -2303,8 +2303,8 @@ class Image:
|
|||
def rotate(
|
||||
self,
|
||||
angle: float,
|
||||
resample: int = Resampling.NEAREST,
|
||||
expand: bool = False,
|
||||
resample: Resampling = Resampling.NEAREST,
|
||||
expand: int | bool = False,
|
||||
center: tuple[int, int] | None = None,
|
||||
translate: tuple[int, int] | None = None,
|
||||
fillcolor: float | tuple[float, ...] | str | None = None,
|
||||
|
@ -2617,8 +2617,8 @@ class Image:
|
|||
|
||||
def thumbnail(
|
||||
self,
|
||||
size: tuple[int, int],
|
||||
resample: int = Resampling.BICUBIC,
|
||||
size: tuple[float, float],
|
||||
resample: Resampling = Resampling.BICUBIC,
|
||||
reducing_gap: float = 2.0,
|
||||
) -> None:
|
||||
"""
|
||||
|
@ -2953,7 +2953,7 @@ class ImageTransformHandler:
|
|||
self,
|
||||
size: tuple[int, int],
|
||||
image: Image,
|
||||
**options: str | int | tuple[int, ...] | list[int],
|
||||
**options: Any,
|
||||
) -> Image:
|
||||
pass
|
||||
|
||||
|
|
|
@ -95,7 +95,9 @@ class ImageDraw:
|
|||
if TYPE_CHECKING:
|
||||
from . import ImageFont
|
||||
|
||||
def getfont(self) -> ImageFont.FreeTypeFont | ImageFont.ImageFont:
|
||||
def getfont(
|
||||
self,
|
||||
) -> ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont:
|
||||
"""
|
||||
Get the current default font.
|
||||
|
||||
|
@ -122,14 +124,13 @@ class ImageDraw:
|
|||
|
||||
def _getfont(
|
||||
self, font_size: float | None
|
||||
) -> ImageFont.FreeTypeFont | ImageFont.ImageFont:
|
||||
) -> ImageFont.ImageFont | ImageFont.FreeTypeFont | ImageFont.TransposedFont:
|
||||
if font_size is not None:
|
||||
from . import ImageFont
|
||||
|
||||
font = ImageFont.load_default(font_size)
|
||||
return ImageFont.load_default(font_size)
|
||||
else:
|
||||
font = self.getfont()
|
||||
return font
|
||||
return self.getfont()
|
||||
|
||||
def _getink(self, ink, fill=None) -> tuple[int | None, int | None]:
|
||||
if ink is None and fill is None:
|
||||
|
|
|
@ -361,7 +361,7 @@ class FreeTypeFont:
|
|||
text: str,
|
||||
mode: str = "",
|
||||
direction: str | None = None,
|
||||
features: str | None = None,
|
||||
features: list[str] | None = None,
|
||||
language: str | None = None,
|
||||
stroke_width: float = 0,
|
||||
anchor: str | None = None,
|
||||
|
|
|
@ -6,7 +6,7 @@ class _Axis(TypedDict):
|
|||
minimum: int | None
|
||||
default: int | None
|
||||
maximum: int | None
|
||||
name: str | None
|
||||
name: bytes | None
|
||||
|
||||
class Font:
|
||||
@property
|
||||
|
|
Loading…
Reference in New Issue
Block a user