mirror of
https://github.com/python-pillow/Pillow.git
synced 2025-02-03 05:04:24 +03:00
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
This commit is contained in:
parent
c92f59d758
commit
1aa3886ed7
|
@ -481,9 +481,11 @@ def _getscaleoffset(expr):
|
||||||
# --------------------------------------------------------------------
|
# --------------------------------------------------------------------
|
||||||
# Implementation wrapper
|
# Implementation wrapper
|
||||||
|
|
||||||
|
|
||||||
class _GetDataTransform(Protocol):
|
class _GetDataTransform(Protocol):
|
||||||
def getdata(self) -> tuple[Transform, Sequence[int]]: ...
|
def getdata(self) -> tuple[Transform, Sequence[int]]: ...
|
||||||
|
|
||||||
|
|
||||||
class Image:
|
class Image:
|
||||||
"""
|
"""
|
||||||
This class represents an image object. To create
|
This class represents an image object. To create
|
||||||
|
@ -1689,7 +1691,12 @@ class Image:
|
||||||
return self.im.entropy(extrema)
|
return self.im.entropy(extrema)
|
||||||
return self.im.entropy()
|
return self.im.entropy()
|
||||||
|
|
||||||
def paste(self, im: Image | str | int | tuple[int, ...], box: tuple[int, int, int, int] | tuple[int, int] | None = None, mask: Image | None = None) -> None:
|
def paste(
|
||||||
|
self,
|
||||||
|
im: Image | str | int | tuple[int, ...],
|
||||||
|
box: tuple[int, int, int, int] | tuple[int, int] | None = None,
|
||||||
|
mask: Image | None = None,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Pastes another image into this image. The box argument is either
|
Pastes another image into this image. The box argument is either
|
||||||
a 2-tuple giving the upper left corner, a 4-tuple defining the
|
a 2-tuple giving the upper left corner, a 4-tuple defining the
|
||||||
|
@ -2124,7 +2131,13 @@ class Image:
|
||||||
min(self.size[1], math.ceil(box[3] + support_y)),
|
min(self.size[1], math.ceil(box[3] + support_y)),
|
||||||
)
|
)
|
||||||
|
|
||||||
def resize(self, size: tuple[int, int], resample: Resampling | None = None, box: tuple[float, float, float, float] | None = None, reducing_gap: float | None = None) -> Image:
|
def resize(
|
||||||
|
self,
|
||||||
|
size: tuple[int, int],
|
||||||
|
resample: Resampling | None = None,
|
||||||
|
box: tuple[float, float, float, float] | None = None,
|
||||||
|
reducing_gap: float | None = None,
|
||||||
|
) -> Image:
|
||||||
"""
|
"""
|
||||||
Returns a resized copy of this image.
|
Returns a resized copy of this image.
|
||||||
|
|
||||||
|
@ -2230,7 +2243,11 @@ class Image:
|
||||||
|
|
||||||
return self._new(self.im.resize(size, resample, box))
|
return self._new(self.im.resize(size, resample, box))
|
||||||
|
|
||||||
def reduce(self, factor: int | tuple[int, int], box: tuple[int, int, int, int] | None = None) -> Image:
|
def reduce(
|
||||||
|
self,
|
||||||
|
factor: int | tuple[int, int],
|
||||||
|
box: tuple[int, int, int, int] | None = None,
|
||||||
|
) -> Image:
|
||||||
"""
|
"""
|
||||||
Returns a copy of the image reduced ``factor`` times.
|
Returns a copy of the image reduced ``factor`` times.
|
||||||
If the size of the image is not dividable by ``factor``,
|
If the size of the image is not dividable by ``factor``,
|
||||||
|
@ -2578,7 +2595,12 @@ class Image:
|
||||||
"""
|
"""
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def thumbnail(self, size: tuple[int, int], resample: Resampling = Resampling.BICUBIC, reducing_gap: float = 2.0) -> None:
|
def thumbnail(
|
||||||
|
self,
|
||||||
|
size: tuple[int, int],
|
||||||
|
resample: Resampling = Resampling.BICUBIC,
|
||||||
|
reducing_gap: float = 2.0,
|
||||||
|
) -> None:
|
||||||
"""
|
"""
|
||||||
Make this image into a thumbnail. This method modifies the
|
Make this image into a thumbnail. This method modifies the
|
||||||
image to contain a thumbnail version of itself, no larger than
|
image to contain a thumbnail version of itself, no larger than
|
||||||
|
|
|
@ -158,7 +158,9 @@ class ImageFont:
|
||||||
Image._decompression_bomb_check(self.font.getsize(text))
|
Image._decompression_bomb_check(self.font.getsize(text))
|
||||||
return self.font.getmask(text, mode)
|
return self.font.getmask(text, mode)
|
||||||
|
|
||||||
def getbbox(self, text: str, *args: object, **kwargs: object) -> tuple[int, int, int, int]:
|
def getbbox(
|
||||||
|
self, text: str, *args: object, **kwargs: object
|
||||||
|
) -> tuple[int, int, int, int]:
|
||||||
"""
|
"""
|
||||||
Returns bounding box (in pixels) of given text.
|
Returns bounding box (in pixels) of given text.
|
||||||
|
|
||||||
|
@ -274,7 +276,9 @@ class FreeTypeFont:
|
||||||
"""
|
"""
|
||||||
return self.font.ascent, self.font.descent
|
return self.font.ascent, self.font.descent
|
||||||
|
|
||||||
def getlength(self, text: str, mode="", direction=None, features=None, language=None) -> float:
|
def getlength(
|
||||||
|
self, text: str, mode="", direction=None, features=None, language=None
|
||||||
|
) -> float:
|
||||||
"""
|
"""
|
||||||
Returns length (in pixels with 1/64 precision) of given text when rendered
|
Returns length (in pixels with 1/64 precision) of given text when rendered
|
||||||
in font with provided direction, features, and language.
|
in font with provided direction, features, and language.
|
||||||
|
@ -744,7 +748,13 @@ def load(filename: str) -> ImageFont:
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
|
||||||
def truetype(font: StrOrBytesPath | BinaryIO | None = None, size: float = 10, index: int = 0, encoding: str = "", layout_engine: Layout | None = None) -> FreeTypeFont:
|
def truetype(
|
||||||
|
font: StrOrBytesPath | BinaryIO | None = None,
|
||||||
|
size: float = 10,
|
||||||
|
index: int = 0,
|
||||||
|
encoding: str = "",
|
||||||
|
layout_engine: Layout | None = None,
|
||||||
|
) -> FreeTypeFont:
|
||||||
"""
|
"""
|
||||||
Load a TrueType or OpenType font from a file or file-like object,
|
Load a TrueType or OpenType font from a file or file-like object,
|
||||||
and create a font object.
|
and create a font object.
|
||||||
|
|
|
@ -6,7 +6,6 @@ class _Axis(TypedDict):
|
||||||
maximum: int | None
|
maximum: int | None
|
||||||
name: str | None
|
name: str | None
|
||||||
|
|
||||||
|
|
||||||
class Font:
|
class Font:
|
||||||
@property
|
@property
|
||||||
def family(self) -> str | None: ...
|
def family(self) -> str | None: ...
|
||||||
|
@ -24,15 +23,38 @@ class Font:
|
||||||
def y_ppem(self) -> int: ...
|
def y_ppem(self) -> int: ...
|
||||||
@property
|
@property
|
||||||
def glyphs(self) -> int: ...
|
def glyphs(self) -> int: ...
|
||||||
|
def render(
|
||||||
def render(self, string: str, fill, mode = ..., dir = ..., features = ..., lang = ..., stroke_width = ..., anchor = ..., foreground_ink_long = ..., x_start = ..., y_start = ..., /) -> tuple[Any, tuple[int, int]]: ...
|
self,
|
||||||
def getsize(self, string: str, mode = ..., dir = ..., features = ..., lang = ..., anchor = ..., /) -> tuple[tuple[int, int], tuple[int, int]]: ...
|
string: str,
|
||||||
def getlength(self, string: str, mode = ..., dir = ..., features = ..., lang = ..., /) -> int: ...
|
fill,
|
||||||
|
mode=...,
|
||||||
|
dir=...,
|
||||||
|
features=...,
|
||||||
|
lang=...,
|
||||||
|
stroke_width=...,
|
||||||
|
anchor=...,
|
||||||
|
foreground_ink_long=...,
|
||||||
|
x_start=...,
|
||||||
|
y_start=...,
|
||||||
|
/,
|
||||||
|
) -> tuple[Any, tuple[int, int]]: ...
|
||||||
|
def getsize(
|
||||||
|
self, string: str, mode=..., dir=..., features=..., lang=..., anchor=..., /
|
||||||
|
) -> tuple[tuple[int, int], tuple[int, int]]: ...
|
||||||
|
def getlength(
|
||||||
|
self, string: str, mode=..., dir=..., features=..., lang=..., /
|
||||||
|
) -> int: ...
|
||||||
def getvarnames(self) -> list[str]: ...
|
def getvarnames(self) -> list[str]: ...
|
||||||
def getvaraxes(self) -> list[_Axis]: ...
|
def getvaraxes(self) -> list[_Axis]: ...
|
||||||
def setvarname(self, instance_index: int, /) -> None: ...
|
def setvarname(self, instance_index: int, /) -> None: ...
|
||||||
def setvaraxes(self, axes: list[float], /) -> None: ...
|
def setvaraxes(self, axes: list[float], /) -> None: ...
|
||||||
|
|
||||||
def getfont(filename: str | bytes | bytearray, size, index = ..., encoding = ..., font_bytes = ..., layout_engine = ...) -> Font: ...
|
def getfont(
|
||||||
|
filename: str | bytes | bytearray,
|
||||||
|
size,
|
||||||
|
index=...,
|
||||||
|
encoding=...,
|
||||||
|
font_bytes=...,
|
||||||
|
layout_engine=...,
|
||||||
|
) -> Font: ...
|
||||||
def __getattr__(name: str) -> Any: ...
|
def __getattr__(name: str) -> Any: ...
|
||||||
|
|
Loading…
Reference in New Issue
Block a user