Skip to content

Commit ff92845

Browse files
committed
address comment
1 parent bf8298c commit ff92845

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

thumbhash/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
from thumbhash.decode import thumbhash_to_image as thumbhash_to_image
2-
from thumbhash.encode import image_to_thumbhash as image_to_thumbhash, pil_image_to_thumbhash
2+
from thumbhash.encode import image_to_thumbhash as image_to_thumbhash
33

4-
__all__ = ["image_to_thumbhash", "thumbhash_to_image", "pil_image_to_thumbhash"]
4+
__all__ = ["image_to_thumbhash", "thumbhash_to_image"]

thumbhash/encode.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
from thumbhash.hash import Hash
1010

1111

12-
def image_to_thumbhash(
13-
image: Union[str, bytes, Path, BinaryIO],
14-
) -> str:
15-
return pil_image_to_thumbhash(Image.open(image))
12+
def image_to_thumbhash(image: Union[str, bytes, Path, BinaryIO, Image.Image]) -> str:
13+
if not isinstance(image, Image.Image):
14+
image = Image.open(image)
1615

17-
18-
def pil_image_to_thumbhash(image: Image.Image) -> str:
1916
m_image = exif_transpose(image).convert("RGBA")
2017

2118
m_image.thumbnail((100, 100))

0 commit comments

Comments
 (0)