bodqhrohro / giftolottie

Converts animated GIFs into animated stickers for Telegram (*.tgs)
MIT License
235 stars 55 forks source link

error while converting to .gif #5

Open edap opened 4 years ago

edap commented 4 years ago
Traceback (most recent call last):
  File "read.py", line 22, in <module>
    frames, exts, image_specs = vendor.gif2numpy.convert(tmpfile.name, BGR2RGB=False)
  File "/media/data/Sources/giftolottie/vendor/gif2numpy.py", line 660, in convert
    transp_idx = color_table[exts[-1]['transparent_idx']] # RGB -> RGB
IndexError: list index out of range
AitakattaSora commented 4 years ago

I have the same error. All requirement and gifsicle are installed

RtYkk commented 4 years ago

The same and how to solve it??

ivan-sapeha commented 4 years ago

@edap @RtYkk @ExistentialMisery you have to modify your gif for example via https://ezgif.com/optimize with "Optimization method: Optimize transparency" image

Drjacky commented 2 years ago

Didn't help. Mine is just a simple gif: Pivot_Wave

bodqhrohro commented 2 years ago

This file has the transparent color index set to 255, despite the palette contains only 4 colors (among which only 2 are used, thus it gets even worse after optimizations), hence the error. It can be circumvented by setting some correct index as transparent:

@bq:17:01:42:/tmp/dl$ gifsicle -t 0 185141255-111b401c-741e-4b9b-8dbd-a9117e16c3ec.gif > 185141255-111b401c-741e-4b9b-8dbd-a9117e16c3ec-2.gif 
@bq:17:01:50:/tmp/dl$ python3 /data/progs/python/giftolottie/read.py 185141255-111b401c-741e-4b9b-8dbd-a9117e16c3ec-2.gif /tmp/hi.tgs
@bq:17:02:47:/tmp/dl$ ls -l /tmp/hi.tgs 
-rw-r--r-- 1 bodqhrohro bodqhrohro 16796 авг 17 17:02 /tmp/hi.tgs
@bq:17:03:22:/tmp/dl$ 

or forcefully extending the palette so it always has 256 colors.

Still it should be handled better by gif2numpy (AFAIR, I already had made some ugly hacks to make it support transparency at all).

And I remind there's generally no need in this tool anymore as Telegram now supports WebM stickers natively, unless you want to add new stickers to an existing animated pack, or use the Lottie output beyond Telegram :P

Drjacky commented 2 years ago

@bodqhrohro Yeah, what I was looking for is using Telegram stickers in Lottie. This is my solution for that: https://stackoverflow.com/a/71830351/421467

bodqhrohro commented 2 years ago

The full-fledged Lottie format has much more possibilities than the restricted TGS, including an ability to embed raster frames, so there's no need in such a quirky tool for that.