Skip to content

Commit 3466632

Browse files
authored
Merge pull request #8 from yupbank/allow-pil-images
2 parents 34d3920 + 2460745 commit 3466632

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

thumbhash/encode.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010

1111

1212
def image_to_thumbhash(
13-
image: Union[str, bytes, Path, BinaryIO],
13+
image: Union[str, bytes, Path, BinaryIO, Image.Image],
1414
) -> str:
15-
m_image = exif_transpose(Image.open(image)).convert("RGBA")
15+
if not isinstance(image, Image.Image):
16+
image = Image.open(image)
17+
18+
m_image = exif_transpose(image).convert("RGBA")
1619

1720
m_image.thumbnail((100, 100))
1821

0 commit comments

Comments
 (0)