Skip to content

Converts animated Telegram stickers (*.tgs) to animated GIFs (.gif)

License

Notifications You must be signed in to change notification settings

clansty/tgs-to-gif

 
 

Repository files navigation

Animated stickers for Telegram (*.tgs) to animated GIF/WEBP converter CircleCI


To easily convert stickers to GIFs you can use Telegram Bot

👉 https://t.me/tgstogifbot 👈


How to use

There are several ways:

Using Docker

  1. Build the image:

    docker build --platform linux/x86_64 -t tgs-to-gif .
  2. Convert! Pass directory with stickers and run:

    • Convert to GIF:
      docker run -e FORMAT=gif --platform linux/x86_64 --rm -v <path to directory with stickers>:/source tgs-to-gif
    • Convert to WEBP:
      docker run -e FORMAT=webp --platform linux/x86_64 --rm -v <path to directory with stickers>:/source tgs-to-gif

    Results will be saved next to each source sticker file in the same directory.

Building from sources

  1. Install dependencies

    1. Make sure you have C++17 compiler, make, cmake and conan tools installed; otherwise install them
    2. Make sure you have the tools installed:
      • gifski if you want to convert to GIF
      • img2webp if you want to convert to WEBP
    3. Install conan dependencies
      conan install .
      
  2. Build

    cmake CMakeLists.txt && make
    
    ARM troubleshooting (including Apple M1) Run the following command and try again:
    echo '#if defined(__ARM_NEON__)
    
    #include "vdrawhelper.h"
    
    void memfill32(uint32_t *dest, uint32_t value, int length)
    {
        memset(dest, value, length);
    }
    
    static void color_SourceOver(uint32_t *dest, int length, uint32_t color, uint32_t alpha)
    {
        int ialpha, i;
    
        if (alpha != 255) color = BYTE_MUL(color, alpha);
        ialpha = 255 - vAlpha(color);
        for (i = 0; i < length; ++i) dest[i] = color + BYTE_MUL(dest[i], ialpha);
    }
    
    void RenderFuncTable::neon()
    {
        updateColor(BlendMode::Src , color_SourceOver);
    }
    #endif
    ' > lib/src/rlottie/src/vector/vdrawhelper_neon.cpp
    
  3. Convert!

    • To convert to GIF:
      ./tgs_to_gif.sh /home/ed/Downloads/sticker.tgs
      
    • To convert to WEBP:
      ./tgs_to_webp.sh /home/ed/Downloads/sticker.tgs
      

    Results will be saved next to each source sticker file in the same directory.

CLI arguments

$ ./tgs_to_gif.sh --help 
usage: tgs_to_gif.sh [--help] [--output OUTPUT] [--height HEIGHT] [--width WIDTH] [--fps FPS] path

Animated sticker for Telegram (*.tgs) to animated .gif converter

Positional arguments:
 path             Path to .tgs file to convert

Optional arguments:
 -h, --help       show this help message and exit
 --output OUTPUT  Output file path
 --height HEIGHT  Output image height. Default: 512
 --width WIDTH    Output image width. Default: 512
 --fps FPS        Output frame rate. Default: 50
 --quality FPS    Output quality. Default: 90

Notices

You can download .tgs files using @Stickerdownloadbot.

About

Converts animated Telegram stickers (*.tgs) to animated GIFs (.gif)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • C++ 81.3%
  • Shell 8.3%
  • CMake 5.8%
  • Dockerfile 4.6%