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

Telegram sticker packs with animated stickers fail to import #79

Open
Azel04 opened this issue Aug 8, 2024 · 2 comments
Open

Telegram sticker packs with animated stickers fail to import #79

Azel04 opened this issue Aug 8, 2024 · 2 comments

Comments

@Azel04
Copy link

Azel04 commented Aug 8, 2024

Attempting to import any Telegram Sticker Pack with an animated sticker results in this error

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/home/REDACTED/stickerpicker/.venv/bin/sticker-import", line 8, in
sys.exit(cmd())
^^^^^
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/sticker/stickerimport.py", line 161, in cmd
asyncio.get_event_loop().run_until_complete(main(parser.parse_args()))
File "/usr/lib/python3.12/asyncio/base_events.py", line 687, in run_until_complete
return future.result()
^^^^^^^^^^^^^^^
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/sticker/stickerimport.py", line 153, in main
await reupload_pack(client, pack, args.output_dir)
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/sticker/stickerimport.py", line 84, in reupload_pack
reuploaded_documents[document.id] = await reupload_document(client, document)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/sticker/stickerimport.py", line 36, in reupload_document
data, width, height = util.convert_image(data)
^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/sticker/lib/util.py", line 28, in convert_image
image: Image.Image = Image.open(BytesIO(data)).convert("RGBA")
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/REDACTED/stickerpicker/.venv/lib/python3.12/site-packages/PIL/Image.py", line 3498, in open
raise UnidentifiedImageError(msg)
PIL.UnidentifiedImageError: cannot identify image file <_io.BytesIO object at 0x74c06caf7600>

The sticker pack i tried is this one: https://t.me/addstickers/precure2

@robertototaro
Copy link

I can reproduce this problem with other Telegram sticker packs, for example:
https://t.me/addstickers/Hedgehoge
https://t.me/addstickers/NickWallowPig
https://t.me/addstickers/MooingCow

@Azel04
Copy link
Author

Azel04 commented Sep 6, 2024

After quickly looking into the code, i think there may be a way to fix this.

Animated Telegram Stickers use the WEBM format which apparently isn't compatible with the image conversion library used here.

Maybe we can convert WEBM to another format like GIF with FFMpeg? Or maybe we can change the image conversion library to another one that supports WEBM.

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

2 participants