Skip to content

Commit

Permalink
fix compatibility with 10.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Md Shahriyar Alam committed Dec 1, 2023
1 parent 24c30ae commit afce445
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
3 changes: 2 additions & 1 deletion easy_pil/font.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ def __init__(self, path: str, size: int = 10, **kwargs) -> None:
self.font = ImageFont.truetype(path, size=size, **kwargs)

def getsize(self, text: str):
return self.font.getsize(text)
bbox = self.font.getbbox(text)
return bbox[2], bbox[3]

@staticmethod
@lru_cache(32)
Expand Down
4 changes: 2 additions & 2 deletions easy_pil/gif_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from io import BytesIO
from pathlib import Path
from typing import List, Union
from typing import List, Union, Tuple

from PIL import Image as PilImage, ImageSequence
from PIL.GifImagePlugin import GifImageFile
Expand All @@ -21,7 +21,7 @@ def __init__(self, image: Union[str, BytesIO, Path, GifImageFile]):
self.frames: List[Editor] = list(
map(lambda x: Editor(x), self.original_frames)
)
self.size: List[int, int] = list(self.image.size)
self.size: Tuple[int, int] = self.image.size

def __getattr__(self, name):
def wrapper(*args, **kwargs):
Expand Down
3 changes: 2 additions & 1 deletion easy_pil/text.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,5 @@ def __init__(
self.font = font

def getsize(self):
return self.font.getsize(self.text)
bbox = self.font.getbbox(self.text)
return bbox[2], bbox[3]
4 changes: 2 additions & 2 deletions easy_pil/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import functools
from functools import lru_cache
from io import BytesIO
from typing import Union
from typing import Union, Optional

import aiohttp
import requests
Expand Down Expand Up @@ -52,7 +52,7 @@ def load_image(

@cached(ttl=60 * 60 * 24)
async def load_image_async(
link: str, session: aiohttp.ClientSession = None, raw: bool = False
link: str, session: Optional[aiohttp.ClientSession] = None, raw: bool = False
) -> Union[Image.Image, GifImageFile]:
"""Load image from link (async)
Expand Down

0 comments on commit afce445

Please sign in to comment.