pilmoji icon indicating copy to clipboard operation
pilmoji copied to clipboard

PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000236633A08B0>

Open knasiotis opened this issue 2 years ago • 2 comments

File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\pilmoji\core.py", line 309, in text with Image.open(stream).convert('RGBA') as asset: File "C:\Users\user\AppData\Local\Programs\Python\Python39\lib\site-packages\PIL\Image.py", line 3123, in open raise UnidentifiedImageError( PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x00000236633A08B0>

This error would make you think in the beginning that there was something with an image you created or loaded. However it is just a badly explained error of pilmoji and it happens when an emoji is not found at the emojicdn, which is very common if you try different styles. I could design my own CDN class of course However this took me many hours to debug because the error isn't that explanatory. In our case, let's say I was trying to use this emoji: https://emojicdn.elk.sh/🥳?style=facebook. This query returns a string "Emoji exists, but style couldn’t be found". The emojiCDN does not return an alternative .png and that causes pilmoji to throw the error. My problem with that is mostly that the error is not descriptive of what happened, it makes you assume that there are problems with the image you're rendering and not of a different CDN response.

knasiotis avatar Jun 23 '22 12:06 knasiotis

I'll look into this, I'll leave this issue open in the meantime

jay3332 avatar Jun 28 '22 23:06 jay3332

2023-07-09T06:04:16.197948640Z File "/opt/venv/lib/python3.11/site-packages/pilmoji/core.py", line 318, in text 2023-07-09T06:04:16.197953960Z with Image.open(stream).convert('RGBA') as asset: 2023-07-09T06:04:16.197959010Z ^^^^^^^^^^^^^^^^^^ 2023-07-09T06:04:16.197963520Z File "/opt/venv/lib/python3.11/site-packages/PIL/Image.py", line 3280, in open 2023-07-09T06:04:16.197968370Z raise UnidentifiedImageError(msg) 2023-07-09T06:04:16.197973080Z PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x7f1751e3b650>

Hmm same error, @jay3332 mind fixing it now pleaseeeeeeeeeee ?

annihilatorrrr avatar Jul 11 '23 14:07 annihilatorrrr