Skip to content

Commit

Permalink
🔧 rm need of PIL dep
Browse files Browse the repository at this point in the history
  • Loading branch information
shroominic committed May 17, 2024
1 parent c7504e4 commit 1814615
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/funcchain/syntax/input_types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@

if TYPE_CHECKING:
from PIL.Image import Image as PImage
from PIL.Image import open as pil_open
else:
PImage = type("PImage")
pil_open = lambda x: x # noqa


class Image:
Expand Down Expand Up @@ -63,10 +65,10 @@ def to_bytes(self) -> bytes:
return base64.b64decode(base64_str)

def to_pillow(self) -> PImage:
from io import BytesIO # type: ignore
from io import BytesIO

image_bytes = self.to_bytes()
return PImage.open(BytesIO(image_bytes))
return pil_open(BytesIO(image_bytes))

def to_file(self, path: str) -> None:
open(path, "wb").write(self.to_bytes())
Expand Down

0 comments on commit 1814615

Please sign in to comment.