diff --git a/stubs/Pillow/PIL/ImageChops.pyi b/stubs/Pillow/PIL/ImageChops.pyi index 9b8538e9f..0e9f53046 100644 --- a/stubs/Pillow/PIL/ImageChops.pyi +++ b/stubs/Pillow/PIL/ImageChops.pyi @@ -1,23 +1,23 @@ -from typing import Any +from .Image import Image -def constant(image, value): ... -def duplicate(image): ... -def invert(image): ... -def lighter(image1, image2): ... -def darker(image1, image2): ... -def difference(image1, image2): ... -def multiply(image1, image2): ... -def screen(image1, image2): ... -def soft_light(image1, image2): ... -def hard_light(image1, image2): ... -def overlay(image1, image2): ... -def add(image1, image2, scale: float = ..., offset: int = ...): ... -def subtract(image1, image2, scale: float = ..., offset: int = ...): ... -def add_modulo(image1, image2): ... -def subtract_modulo(image1, image2): ... -def logical_and(image1, image2): ... -def logical_or(image1, image2): ... -def logical_xor(image1, image2): ... -def blend(image1, image2, alpha): ... -def composite(image1, image2, mask): ... -def offset(image, xoffset, yoffset: Any | None = ...): ... +def constant(image: Image, value: int) -> Image: ... +def duplicate(image: Image) -> Image: ... +def invert(image: Image) -> Image: ... +def lighter(image1: Image, image2: Image) -> Image: ... +def darker(image1: Image, image2: Image) -> Image: ... +def difference(image1: Image, image2: Image) -> Image: ... +def multiply(image1: Image, image2: Image) -> Image: ... +def screen(image1: Image, image2: Image) -> Image: ... +def soft_light(image1: Image, image2: Image) -> Image: ... +def hard_light(image1: Image, image2: Image) -> Image: ... +def overlay(image1: Image, image2: Image) -> Image: ... +def add(image1: Image, image2: Image, scale: float = ..., offset: int = ...) -> Image: ... +def subtract(image1: Image, image2: Image, scale: float = ..., offset: int = ...) -> Image: ... +def add_modulo(image1: Image, image2: Image) -> Image: ... +def subtract_modulo(image1: Image, image2: Image) -> Image: ... +def logical_and(image1: Image, image2: Image) -> Image: ... +def logical_or(image1: Image, image2: Image) -> Image: ... +def logical_xor(image1: Image, image2: Image) -> Image: ... +def blend(image1: Image, image2: Image, alpha: float) -> Image: ... +def composite(image1: Image, image2: Image, mask: Image) -> Image: ... +def offset(image: Image, xoffset: int, yoffset: int | None = ...) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageDraw.pyi b/stubs/Pillow/PIL/ImageDraw.pyi index c7d284fb5..795f93e43 100644 --- a/stubs/Pillow/PIL/ImageDraw.pyi +++ b/stubs/Pillow/PIL/ImageDraw.pyi @@ -1,21 +1,25 @@ from collections.abc import Container -from typing import Any, Tuple, Union, overload +from typing import Any, Sequence, Tuple, Union, overload from typing_extensions import Literal from .Image import Image from .ImageFont import _Font -_Ink = Union[str, Tuple[int, int, int]] +_Ink = Union[str, int, Tuple[int, int, int]] +_XY = Sequence[Union[float, Tuple[float, float]]] +_Outline = Any class ImageDraw: def __init__(self, im: Image, mode: str | None = ...) -> None: ... def getfont(self): ... - def arc(self, xy, start, end, fill: _Ink | None = ..., width: float = ...) -> None: ... - def bitmap(self, xy, bitmap, fill: _Ink | None = ...) -> None: ... - def chord(self, xy, start, end, fill: _Ink | None = ..., outline: _Ink | None = ..., width: float = ...) -> None: ... - def ellipse(self, xy, fill: _Ink | None = ..., outline: _Ink | None = ..., width: float = ...) -> None: ... - def line(self, xy, fill: _Ink | None = ..., width: float = ..., joint=...) -> None: ... - def shape(self, shape, fill: _Ink | None = ..., outline: _Ink | None = ...) -> None: ... + def arc(self, xy: _XY, start: float, end: float, fill: _Ink | None = ..., width: float = ...) -> None: ... + def bitmap(self, xy: _XY, bitmap: Image, fill: _Ink | None = ...) -> None: ... + def chord( + self, xy: _XY, start: float, end: float, fill: _Ink | None = ..., outline: _Ink | None = ..., width: float = ... + ) -> None: ... + def ellipse(self, xy: _XY, fill: _Ink | None = ..., outline: _Ink | None = ..., width: float = ...) -> None: ... + def line(self, xy: _XY, fill: _Ink | None = ..., width: float = ..., joint: Literal["curve"] | None = ...) -> None: ... + def shape(self, shape: _Outline, fill: _Ink | None = ..., outline: _Ink | None = ...) -> None: ... def pieslice( self, xy: tuple[tuple[float, float], tuple[float, float]], @@ -25,11 +29,16 @@ class ImageDraw: outline: _Ink | None = ..., width: float = ..., ) -> None: ... - def point(self, xy, fill: _Ink | None = ...) -> None: ... - def polygon(self, xy, fill: _Ink | None = ..., outline: _Ink | None = ...) -> None: ... + def point(self, xy: _XY, fill: _Ink | None = ...) -> None: ... + def polygon(self, xy: _XY, fill: _Ink | None = ..., outline: _Ink | None = ...) -> None: ... def regular_polygon( - self, bounding_circle, n_sides: int, rotation: float = ..., fill: _Ink | None = ..., outline: _Ink | None = ... - ): ... + self, + bounding_circle: tuple[float, float] | tuple[float, float, float] | list[int], + n_sides: int, + rotation: float = ..., + fill: _Ink | None = ..., + outline: _Ink | None = ..., + ) -> None: ... def rectangle( self, xy: tuple[float, float, float, float] | tuple[tuple[float, float], tuple[float, float]], @@ -51,11 +60,11 @@ class ImageDraw: text: str | bytes, fill: _Ink | None = ..., font: _Font | None = ..., - anchor=..., + anchor: str | None = ..., spacing: float = ..., align: Literal["left", "center", "right"] = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., - features=..., + features: Sequence[str] | None = ..., language: str | None = ..., stroke_width: float = ..., stroke_fill: _Ink | None = ..., @@ -69,7 +78,7 @@ class ImageDraw: text: str | bytes, fill: _Ink | None = ..., font: _Font | None = ..., - anchor: Any | None = ..., + anchor: str | None = ..., spacing: float = ..., align: Literal["left", "center", "right"] = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., @@ -85,7 +94,7 @@ class ImageDraw: font: _Font | None = ..., spacing: float = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., - features=..., + features: Sequence[str] | None = ..., language: str | None = ..., stroke_width: float = ..., ) -> tuple[int, int]: ... @@ -95,7 +104,7 @@ class ImageDraw: font: _Font | None = ..., spacing: float = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., - features=..., + features: Sequence[str] | None = ..., language: str | None = ..., stroke_width: float = ..., ) -> tuple[int, int]: ... @@ -104,7 +113,7 @@ class ImageDraw: text: str | bytes, font: _Font | None = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., - features=..., + features: Sequence[str] | None = ..., language: str | None = ..., embedded_color: bool = ..., ) -> int: ... @@ -113,7 +122,7 @@ class ImageDraw: xy: tuple[float, float], text: str | bytes, font: _Font | None = ..., - anchor: Any | None = ..., + anchor: str | None = ..., spacing: float = ..., align: Literal["left", "center", "right"] = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., @@ -127,7 +136,7 @@ class ImageDraw: xy: tuple[float, float], text: str | bytes, font: _Font | None = ..., - anchor: Any | None = ..., + anchor: str | None = ..., spacing: float = ..., align: Literal["left", "center", "right"] = ..., direction: Literal["rtl", "ltr", "ttb"] | None = ..., @@ -138,9 +147,7 @@ class ImageDraw: ) -> tuple[int, int, int, int]: ... def Draw(im: Image, mode: str | None = ...) -> ImageDraw: ... - -Outline: Any - +def Outline() -> _Outline: ... @overload def getdraw(im: None = ..., hints: Container[Literal["nicest"]] | None = ...) -> tuple[None, Any]: ... @overload diff --git a/stubs/Pillow/PIL/ImageEnhance.pyi b/stubs/Pillow/PIL/ImageEnhance.pyi index f38ece1c5..6f0afa8d7 100644 --- a/stubs/Pillow/PIL/ImageEnhance.pyi +++ b/stubs/Pillow/PIL/ImageEnhance.pyi @@ -1,25 +1,25 @@ -from typing import Any +from .Image import Image class _Enhance: - def enhance(self, factor): ... + def enhance(self, factor: float) -> Image: ... class Color(_Enhance): - image: Any + image: Image intermediate_mode: str - degenerate: Any - def __init__(self, image) -> None: ... + degenerate: Image + def __init__(self, image: Image) -> None: ... class Contrast(_Enhance): - image: Any - degenerate: Any - def __init__(self, image) -> None: ... + image: Image + degenerate: Image + def __init__(self, image: Image) -> None: ... class Brightness(_Enhance): - image: Any - degenerate: Any - def __init__(self, image) -> None: ... + image: Image + degenerate: Image + def __init__(self, image: Image) -> None: ... class Sharpness(_Enhance): - image: Any - degenerate: Any - def __init__(self, image) -> None: ... + image: Image + degenerate: Image + def __init__(self, image: Image) -> None: ... diff --git a/stubs/Pillow/PIL/ImageFile.pyi b/stubs/Pillow/PIL/ImageFile.pyi index c20f0a042..745509b49 100644 --- a/stubs/Pillow/PIL/ImageFile.pyi +++ b/stubs/Pillow/PIL/ImageFile.pyi @@ -44,7 +44,7 @@ class Parser: def feed(self, data) -> None: ... def __enter__(self: _T) -> _T: ... def __exit__(self, *args: Any) -> None: ... - def close(self): ... + def close(self) -> Image: ... class PyCodecState: xsize: int diff --git a/stubs/Pillow/PIL/ImageFilter.pyi b/stubs/Pillow/PIL/ImageFilter.pyi index 1bb15ad34..af03bce67 100644 --- a/stubs/Pillow/PIL/ImageFilter.pyi +++ b/stubs/Pillow/PIL/ImageFilter.pyi @@ -1,115 +1,137 @@ -from typing import Any +from _typeshed import Self +from typing import Any, Callable, Iterable, Sequence, Tuple, Type +from typing_extensions import Literal + +from .Image import Image + +_FilterArgs = Tuple[Sequence[int], int, int, Sequence[int]] + +# filter image parameters below are the C images, i.e. Image().im. class Filter: ... class MultibandFilter(Filter): ... class BuiltinFilter(MultibandFilter): - def filter(self, image): ... + def filter(self, image) -> Image: ... class Kernel(BuiltinFilter): name: str - filterargs: Any - def __init__(self, size, kernel, scale: Any | None = ..., offset: int = ...): ... + filterargs: _FilterArgs + def __init__(self, size: Sequence[int], kernel: Sequence[int], scale: Any | None = ..., offset: int = ...) -> None: ... class RankFilter(Filter): name: str - size: Any - rank: Any - def __init__(self, size, rank) -> None: ... - def filter(self, image): ... + size: int + rank: int + def __init__(self, size: int, rank: int) -> None: ... + def filter(self, image) -> Image: ... class MedianFilter(RankFilter): name: str - size: Any - rank: Any + size: int + rank: int def __init__(self, size: int = ...) -> None: ... class MinFilter(RankFilter): name: str - size: Any + size: int rank: int def __init__(self, size: int = ...) -> None: ... class MaxFilter(RankFilter): name: str - size: Any - rank: Any + size: int + rank: int def __init__(self, size: int = ...) -> None: ... class ModeFilter(Filter): name: str - size: Any + size: int def __init__(self, size: int = ...) -> None: ... - def filter(self, image): ... + def filter(self, image) -> Image: ... class GaussianBlur(MultibandFilter): name: str - radius: Any - def __init__(self, radius: int = ...) -> None: ... - def filter(self, image): ... + radius: float + def __init__(self, radius: float = ...) -> None: ... + def filter(self, image) -> Image: ... class BoxBlur(MultibandFilter): name: str - radius: Any - def __init__(self, radius) -> None: ... - def filter(self, image): ... + radius: float + def __init__(self, radius: float) -> None: ... + def filter(self, image) -> Image: ... class UnsharpMask(MultibandFilter): name: str - radius: Any - percent: Any - threshold: Any - def __init__(self, radius: int = ..., percent: int = ..., threshold: int = ...) -> None: ... - def filter(self, image): ... + radius: float + percent: int + threshold: int + def __init__(self, radius: float = ..., percent: int = ..., threshold: int = ...) -> None: ... + def filter(self, image) -> Image: ... class BLUR(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class CONTOUR(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class DETAIL(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class EDGE_ENHANCE(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class EDGE_ENHANCE_MORE(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class EMBOSS(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class FIND_EDGES(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class SHARPEN(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class SMOOTH(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class SMOOTH_MORE(BuiltinFilter): name: str - filterargs: Any + filterargs: _FilterArgs class Color3DLUT(MultibandFilter): name: str - size: Any - channels: Any - mode: Any + size: list[int] + channels: int + mode: str | None table: Any - def __init__(self, size, table, channels: int = ..., target_mode: Any | None = ..., **kwargs) -> None: ... + def __init__( + self, size: int | Iterable[int], table, channels: int = ..., target_mode: str | None = ..., **kwargs + ) -> None: ... @classmethod - def generate(cls, size, callback, channels: int = ..., target_mode: Any | None = ...): ... - def transform(self, callback, with_normals: bool = ..., channels: Any | None = ..., target_mode: Any | None = ...): ... - def filter(self, image): ... + def generate( + cls: Type[Self], + size: int | tuple[int, int, int], + callback: Callable[[float, float, float], Iterable[float]], + channels: int = ..., + target_mode: str | None = ..., + ) -> Self: ... + def transform( + self: Self, + callback: Callable[..., Iterable[float]], + with_normals: bool = ..., + channels: Literal[3, 4] | None = ..., + target_mode: Any | None = ..., + ) -> Self: ... + def filter(self, image) -> Image: ... diff --git a/stubs/Pillow/PIL/ImageFont.pyi b/stubs/Pillow/PIL/ImageFont.pyi index e63bf2d5a..aa79a956a 100644 --- a/stubs/Pillow/PIL/ImageFont.pyi +++ b/stubs/Pillow/PIL/ImageFont.pyi @@ -1,4 +1,4 @@ -from _typeshed import SupportsRead +from _typeshed import StrOrBytesPath, SupportsRead from typing import Any, Protocol from typing_extensions import Literal @@ -6,11 +6,11 @@ LAYOUT_BASIC: Literal[0] LAYOUT_RAQM: Literal[1] class _Font(Protocol): - def getmask(self, text: str, mode: str = ..., direction=..., features=...): ... + def getmask(self, text: str | bytes, mode: str = ..., direction=..., features=...): ... class ImageFont: - def getsize(self, text: str, *args, **kwargs) -> tuple[int, int]: ... - def getmask(self, text: str, mode: str = ..., direction=..., features=...): ... + def getsize(self, text: str | bytes, *args, **kwargs) -> tuple[int, int]: ... + def getmask(self, text: str | bytes, mode: str = ..., direction=..., features=...): ... class FreeTypeFont: path: str | bytes | SupportsRead[bytes] | None @@ -27,21 +27,28 @@ class FreeTypeFont: layout_engine: int | None = ..., ) -> None: ... def getname(self) -> tuple[str, str]: ... - def getmetrics(self): ... + def getmetrics(self) -> tuple[int, int]: ... def getlength( self, - text, - mode=..., + text: str | bytes, + mode: str = ..., direction: Literal["ltr", "rtl", "ttb"] | None = ..., features: Any | None = ..., language: str | None = ..., ) -> int: ... def getbbox( - self, text, mode: str = ..., direction=..., features=..., language: str | None = ..., stroke_width: int = ..., anchor=... - ): ... + self, + text: str | bytes, + mode: str = ..., + direction=..., + features=..., + language: str | None = ..., + stroke_width: int = ..., + anchor: str | None = ..., + ) -> tuple[int, int, int, int]: ... def getsize( self, - text, + text: str | bytes, direction: Literal["ltr", "rtl", "ttb"] | None = ..., features: Any | None = ..., language: str | None = ..., @@ -49,51 +56,58 @@ class FreeTypeFont: ) -> tuple[int, int]: ... def getsize_multiline( self, - text, + text: str | bytes, direction: Literal["ltr", "rtl", "ttb"] | None = ..., spacing: float = ..., features: Any | None = ..., language: str | None = ..., stroke_width: float = ..., - ): ... - def getoffset(self, text) -> tuple[int, int]: ... + ) -> tuple[int, int]: ... + def getoffset(self, text: str | bytes) -> tuple[int, int]: ... def getmask( self, - text: str, + text: str | bytes, mode: str = ..., direction: Literal["ltr", "rtl", "ttb"] | None = ..., features: Any | None = ..., language: str | None = ..., stroke_width: float = ..., - anchor=..., + anchor: str | None = ..., ink=..., ): ... def getmask2( self, - text, + text: str | bytes, mode: str = ..., fill=..., direction: Literal["ltr", "rtl", "ttb"] | None = ..., features: Any | None = ..., language: str | None = ..., stroke_width: float = ..., - anchor=..., + anchor: str | None = ..., ink=..., *args, **kwargs, ): ... - def font_variant(self, font=..., size=..., index=..., encoding=..., layout_engine=...): ... + def font_variant( + self, + font: str | bytes | SupportsRead[bytes] | None = ..., + size: int | None = ..., + index: int | None = ..., + encoding: str | None = ..., + layout_engine: int | None = ..., + ) -> FreeTypeFont: ... def get_variation_names(self): ... def set_variation_by_name(self, name): ... def get_variation_axes(self): ... def set_variation_by_axes(self, axes): ... class TransposedFont: - def __init__(self, font, orientation=...): ... - def getsize(self, text, *args, **kwargs): ... - def getmask(self, text, mode: str = ..., *args, **kwargs): ... + def __init__(self, font: _Font, orientation: int | None = ...) -> None: ... + def getsize(self, text: str | bytes, *args, **kwargs) -> tuple[int, int]: ... + def getmask(self, text: str | bytes, mode: str = ..., *args, **kwargs): ... -def load(filename) -> ImageFont: ... +def load(filename: StrOrBytesPath | int) -> ImageFont: ... def truetype( font: str | bytes | SupportsRead[bytes] | None = ..., size: int = ..., diff --git a/stubs/Pillow/PIL/ImageGrab.pyi b/stubs/Pillow/PIL/ImageGrab.pyi index 5d4abaf6a..31411f35d 100644 --- a/stubs/Pillow/PIL/ImageGrab.pyi +++ b/stubs/Pillow/PIL/ImageGrab.pyi @@ -1,4 +1,8 @@ from typing import Any -def grab(bbox: Any | None = ..., include_layered_windows: bool = ..., all_screens: bool = ..., xdisplay: Any | None = ...): ... -def grabclipboard(): ... +from .Image import Image, _Box + +def grab( + bbox: _Box | None = ..., include_layered_windows: bool = ..., all_screens: bool = ..., xdisplay: Any | None = ... +) -> Image: ... +def grabclipboard() -> Image | None: ... diff --git a/stubs/Pillow/PIL/ImageMorph.pyi b/stubs/Pillow/PIL/ImageMorph.pyi index 446946e72..2668787b7 100644 --- a/stubs/Pillow/PIL/ImageMorph.pyi +++ b/stubs/Pillow/PIL/ImageMorph.pyi @@ -1,24 +1,26 @@ -from typing import Any +from _typeshed import StrOrBytesPath -LUT_SIZE: Any -ROTATION_MATRIX: Any -MIRROR_MATRIX: Any +from .Image import Image + +LUT_SIZE: int +ROTATION_MATRIX: list[int] +MIRROR_MATRIX: list[int] class LutBuilder: - patterns: Any - lut: Any - def __init__(self, patterns: Any | None = ..., op_name: Any | None = ...) -> None: ... - def add_patterns(self, patterns) -> None: ... + patterns: list[str] + lut: bytearray + def __init__(self, patterns: list[str] | None = ..., op_name: str | None = ...) -> None: ... + def add_patterns(self, patterns: list[str]) -> None: ... def build_default_lut(self) -> None: ... - def get_lut(self): ... - def build_lut(self): ... + def get_lut(self) -> bytearray: ... + def build_lut(self) -> bytearray: ... class MorphOp: - lut: Any - def __init__(self, lut: Any | None = ..., op_name: Any | None = ..., patterns: Any | None = ...) -> None: ... - def apply(self, image): ... - def match(self, image): ... - def get_on_pixels(self, image): ... - def load_lut(self, filename) -> None: ... - def save_lut(self, filename) -> None: ... - def set_lut(self, lut) -> None: ... + lut: bytearray + def __init__(self, lut: bytearray | None = ..., op_name: str | None = ..., patterns: list[str] | None = ...) -> None: ... + def apply(self, image: Image) -> tuple[int, Image]: ... + def match(self, image: Image) -> list[tuple[int, int]]: ... + def get_on_pixels(self, image: Image) -> list[tuple[int, int]]: ... + def load_lut(self, filename: StrOrBytesPath) -> None: ... + def save_lut(self, filename: StrOrBytesPath) -> None: ... + def set_lut(self, lut: bytearray) -> None: ... diff --git a/stubs/Pillow/PIL/ImageOps.pyi b/stubs/Pillow/PIL/ImageOps.pyi index cff8d5fa4..3322b90e5 100644 --- a/stubs/Pillow/PIL/ImageOps.pyi +++ b/stubs/Pillow/PIL/ImageOps.pyi @@ -1,18 +1,35 @@ -from typing import Any +from typing import Any, Iterable, Protocol -def autocontrast(image, cutoff: int = ..., ignore: Any | None = ..., mask: Any | None = ..., preserve_tone: bool = ...): ... -def colorize(image, black, white, mid: Any | None = ..., blackpoint: int = ..., whitepoint: int = ..., midpoint: int = ...): ... -def pad(image, size, method=..., color: Any | None = ..., centering=...): ... -def crop(image, border: int = ...): ... -def scale(image, factor, resample=...): ... -def deform(image, deformer, resample=...): ... -def equalize(image, mask: Any | None = ...): ... -def expand(image, border: int = ..., fill: int = ...): ... -def fit(image, size, method=..., bleed: float = ..., centering=...): ... -def flip(image): ... -def grayscale(image): ... -def invert(image): ... -def mirror(image): ... -def posterize(image, bits): ... -def solarize(image, threshold: int = ...): ... -def exif_transpose(image): ... +from .Image import Image, _Resample, _Size + +class _Deformer(Protocol): + def getmesh(self, image: Image): ... + +def autocontrast( + image: Image, cutoff: int = ..., ignore: int | None = ..., mask: Image | None = ..., preserve_tone: bool = ... +) -> Image: ... +def colorize( + image: Image, + black: int | str, + white: int | str, + mid: int | str | None = ..., + blackpoint: int = ..., + whitepoint: int = ..., + midpoint: int = ..., +) -> Image: ... +def pad( + image: Image, size: _Size, method: _Resample = ..., color: Any | None = ..., centering: Iterable[float] = ... +) -> Image: ... +def crop(image: Image, border: int = ...) -> Image: ... +def scale(image: Image, factor: float, resample: _Resample = ...) -> Image: ... +def deform(image: Image, deformer: _Deformer, resample: _Resample = ...) -> Image: ... +def equalize(image: Image, mask: Any | None = ...) -> Image: ... +def expand(image: Image, border: int = ..., fill: int = ...) -> Image: ... +def fit(image: Image, size: _Size, method: _Resample = ..., bleed: float = ..., centering: Iterable[float] = ...) -> Image: ... +def flip(image: Image) -> Image: ... +def grayscale(image: Image) -> Image: ... +def invert(image: Image) -> Image: ... +def mirror(image: Image) -> Image: ... +def posterize(image: Image, bits: int) -> Image: ... +def solarize(image: Image, threshold: int = ...) -> Image: ... +def exif_transpose(image: Image) -> Image: ... diff --git a/stubs/Pillow/PIL/ImagePalette.pyi b/stubs/Pillow/PIL/ImagePalette.pyi index adceb249e..63b8b6ce8 100644 --- a/stubs/Pillow/PIL/ImagePalette.pyi +++ b/stubs/Pillow/PIL/ImagePalette.pyi @@ -7,11 +7,11 @@ class ImagePalette: colors: Any dirty: Any def __init__(self, mode: str = ..., palette: Any | None = ..., size: int = ...) -> None: ... - def copy(self): ... + def copy(self) -> ImagePalette: ... def getdata(self): ... - def tobytes(self): ... - tostring: Any - def getcolor(self, color): ... + def tobytes(self) -> bytes: ... + tostring = tobytes + def getcolor(self, color: tuple[int, int, int]) -> int: ... def save(self, fp) -> None: ... def raw(rawmode, data): ... diff --git a/stubs/Pillow/PIL/ImageQt.pyi b/stubs/Pillow/PIL/ImageQt.pyi index 802a51563..8b213852f 100644 --- a/stubs/Pillow/PIL/ImageQt.pyi +++ b/stubs/Pillow/PIL/ImageQt.pyi @@ -1,18 +1,22 @@ from typing import Any +from typing_extensions import Literal + +from .Image import Image QImage = Any # imported from either of {PyQt6,PySide6,PyQt5,PySide2}.QtGui +QPixmap = Any qt_versions: Any qt_is_installed: bool qt_version: Any -def rgb(r, g, b, a: int = ...): ... -def fromqimage(im): ... -def fromqpixmap(im): ... -def align8to32(bytes, width, mode): ... +def rgb(r: int, g: int, b: int, a: int = ...) -> int: ... +def fromqimage(im: Image | QImage) -> Image: ... +def fromqpixmap(im: Image | QImage) -> Image: ... +def align8to32(bytes: bytes, width: int, mode: Literal["1", "L", "P"]) -> bytes: ... class ImageQt(QImage): # type: ignore - def __init__(self, im) -> None: ... + def __init__(self, im: Image) -> None: ... -def toqimage(im): ... -def toqpixmap(im): ... +def toqimage(im: Image) -> ImageQt: ... +def toqpixmap(im: Image) -> QPixmap: ... diff --git a/stubs/Pillow/PIL/PSDraw.pyi b/stubs/Pillow/PIL/PSDraw.pyi index e3db990a6..ccf61e4a5 100644 --- a/stubs/Pillow/PIL/PSDraw.pyi +++ b/stubs/Pillow/PIL/PSDraw.pyi @@ -1,16 +1,18 @@ from typing import Any +from .Image import Image + class PSDraw: fp: Any def __init__(self, fp: Any | None = ...) -> None: ... isofont: Any def begin_document(self, id: Any | None = ...) -> None: ... def end_document(self) -> None: ... - def setfont(self, font, size) -> None: ... - def line(self, xy0, xy1) -> None: ... - def rectangle(self, box) -> None: ... - def text(self, xy, text) -> None: ... - def image(self, box, im, dpi: Any | None = ...) -> None: ... + def setfont(self, font: str, size: int) -> None: ... + def line(self, xy0: tuple[int, int], xy1: tuple[int, int]) -> None: ... + def rectangle(self, box: tuple[int, int, int, int]) -> None: ... + def text(self, xy: tuple[int, int], text: str) -> None: ... + def image(self, box: tuple[int, int, int, int], im: Image, dpi: float | None = ...) -> None: ... EDROFF_PS: str VDI_PS: str