Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
knasiotis opened this issue Jun 23, 2022 · 2 comments

Comments

@knasiotis
Copy link

knasiotis commented Jun 23, 2022

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.

@jay3332
Copy link
Owner

jay3332 commented Jun 28, 2022

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

@annihilatorrrr
Copy link
Contributor

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 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants