laggykiller / sticker-convert

Convert (animated) stickers to/from WhatsApp, Telegram, Signal, Line, Kakao, Viber, Discord, iMessage. Written in Python.
GNU General Public License v2.0
288 stars 16 forks source link

animation converted from tgs using python-lottie may produce corrupted image #5

Closed laggykiller closed 1 year ago

laggykiller commented 1 year ago

Discovered from: https://github.com/laggykiller/sticker-convert/issues/4

An issue is opened upstream: https://gitlab.com/mattbas/python-lottie/-/issues/99

azuredusk10 commented 1 year ago

I noticed this when converting the "Colored Cats" Telegram sticker pack to .apng.

Like you've already reported upstream, I noticed that about half of the stickers from that sticker pack had visual glitches where some of the layers weren't rendered in the converted file. I've attached a couple of examples below.

Original: IMG_A637B3E4BC7D-1

IMG_055DDDCAD3EA-1

Converted, with missing layers:

Screenshot 2022-12-29 at 22 34 27 Screenshot 2022-12-29 at 22 26 08

Hopefully the upstream are able to look into it sometime in the future.

Thanks for reporting this and for all your help.

laggykiller commented 1 year ago

I have written rlottie-python, which provides ctypes binding to librlottie for rendering tgs animation to bitmaps. It should be more reliable than lottie python module.

v1.8.0 now uses rlottie-python for converting tgs to bitmaps image / animation.

@azuredusk10 you may have a try

https://github.com/laggykiller/sticker-convert/releases

azuredusk10 commented 1 year ago

From my initial testing, this bug looks fixed in v 1.9.6. The converted stickers don't have any visual corruptions, and also, they are compressed at a higher quality.

I converted the same "Colored Cats" sticker pack from .tgs to .apng for Signal, changing the minimum acceptable fps in the Signal preset to 15. Previously when I did this, the conversion failed for most stickers because the filesize was too large. However, in this version, none of the stickers failed. The animations in the converted stickers were super smooth and the resolution and colours looked brilliant.

I'd recommend changing the Signal preset so that the minimum accepted fps is higher. For me, a minimum acceptable fps of 15 worked well. The default value of 1 produced some very choppy animations.

With a minimum fps of 15, the tool lowered the resolution more than the frame rate in order to compress the image. Our eyes are more sensitive to frame rates than image resolutions, so an animation with a higher frame rate and a lower resolution will look better to most people than the same animation with a higher resolution and a lower frame rate.

I'll convert a few more Telegram stickers with minimum fps set to 15 and see how it goes.

For your reference, here is the converted "Colored Cats" sticker pack. Signal conversion preset, modified so that the minimum fps was 15. 6 steps.

Incredible, incredible work. Can't wait to convert some more packs with this. Thank you!