Skip to content

Commit

Permalink
🔧 fix 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 7c860c9 commit 2b5fec2
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/funcchain/utils/image.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


def image_to_base64_url(image: Image) -> str:
Expand All @@ -28,9 +30,7 @@ def pillow_image_to_base64_url(image: PImage) -> str:


def base64_url_to_pillow_image(base64_url: str) -> PImage:
from PIL.Image import Image as PImage

base64_image = base64_url.split(",")[1]
image_bytes = b64decode(base64_image)
image = PImage.open(BytesIO(image_bytes))
image = pil_open(BytesIO(image_bytes))
return image

0 comments on commit 2b5fec2

Please sign in to comment.