Skip to content

pil additions #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 26, 2023
Merged
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
27 changes: 26 additions & 1 deletion circuitpython_typing/pil.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* Author(s): Alec Delaney
"""

from typing import Tuple
from typing import Tuple, Optional, Callable
from typing_extensions import Protocol # Safety import for Python 3.7


Expand All @@ -26,6 +26,7 @@ def __getitem__(self, xy: Tuple[int, int]) -> int:
class Image(Protocol):
"""Type annotation for PIL's Image class"""

# pylint: disable=too-many-arguments,invalid-name
@property
def mode(self) -> str:
"""The mode of the image"""
Expand All @@ -36,3 +37,27 @@ def size(self) -> Tuple[int, int]:

def load(self) -> PixelAccess:
"""Load the image for quick pixel access"""

def convert(
self,
mode: str,
matrix: Optional[Tuple],
dither: Callable,
palette: int,
colors: int,
):
"""Returns a converted copy of this image."""

def rotate(
self,
angle: int,
resampling,
expand: int,
center: Tuple[int, int],
translate: Tuple[int, int],
fillcolor: int,
):
"""Returns a rotated copy of this image."""

def getpixel(self, xy: Tuple[int, int]):
"""Returns the pixel value at a given position."""