Skip to content

Commit

Permalink
feat(python): basic type stub
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyoon authored and etemesi254 committed Sep 22, 2024
1 parent cd50623 commit b3b244d
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions crates/zune-python/zil.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import enum
from typing import Literal, overload

import numpy as np
from numpy.typing import NDArray

class ImageFormat(enum.Enum):
FarbFeld = ...
JPEG = ...
PNG = ...
PSD = ...
Unknown = ...
BMP = ...
HDR = ...
JPEG_XL = ...
PPM = ...
Qoi = ...

class ResizeMethod(enum.Enum):
Bilinear = ...
Bicubic = ...

class Image:
@staticmethod
def open(file: str) -> Image: ...
def save(self, file: str, *, format: ImageFormat) -> None: ...
def dimensions(self) -> tuple[int, int]: ...
def width(self) -> int: ...
def height(self) -> int: ...
@overload
def auto_orient(self, *, in_place: Literal[False]) -> Image: ...
@overload
def auto_orient(self, *, in_place: Literal[True]) -> None: ...
def auto_orient(self, *, in_place: bool) -> Image | None: ...
@overload
def resize(
self,
new_width: int,
new_height: int,
method: ResizeMethod,
*,
in_place: Literal[False],
) -> Image: ...
@overload
def resize(
self,
new_width: int,
new_height: int,
method: ResizeMethod,
*,
in_place: Literal[True],
) -> None: ...
def resize(
self, new_width: int, new_height: int, method: ResizeMethod, *, in_place: bool
) -> Image | None: ...
@overload
def crop(
self, width: int, height: int, x: int, y: int, *, in_place: Literal[False]
) -> Image: ...
@overload
def crop(
self, width: int, height: int, x: int, y: int, *, in_place: Literal[True]
) -> None: ...
def crop(
self, width: int, height: int, x: int, y: int, *, in_place: bool
) -> Image | None: ...
def to_numpy(self) -> NDArray[np.uint8]: ...

0 comments on commit b3b244d

Please sign in to comment.