Skip to content

将动画 Telegram 贴纸 (*.tgs) 转换为 GIF / PNG / APNG / WEBP

License

Notifications You must be signed in to change notification settings

hadis898/tgbot-to-gif

 
 

Repository files navigation

Animated stickers for Telegram (*.tgs) to GIF/PNG/APNG/WEBP converter docker workflow


To easily convert stickers to GIFs you can use Telegram Bot:https://t.me/tgstogifbot 👈


How to use

There are two options: run using Docker and run from source.

Using Docker

Replace with directory with stickers and run:

  • Convert to GIF:
    docker run --rm -v <path to directory with stickers>:/source edasriyan/tgs-to-gif
  • Convert to PNG:
    docker run --rm -v <path to directory with stickers>:/source edasriyan/tgs-to-png
  • Convert to APNG:
    docker run --rm -v <path to directory with stickers>:/source edasriyan/tgs-to-apng
  • Convert to WEBP:
    docker run --rm -v <path to directory with stickers>:/source edasriyan/tgs-to-webp

You can provide parameters via env variables:

  • HEIGHT: Output image height. Default: 512
  • WIDTH: Output image width. Default: 512
  • FPS: Output frame rate. Default: apng,png,webp - 60; gif - 50
  • QUALITY: Output quality. Default: 90
  • THREADS: Number of threads to use. Default: number of CPUs

Example:

docker run --rm -e HEIGHT=256 -e WIDTH=256 -e FPS=30 -v /home/ed/Downloads/stickers:/source edasriyan/tgs-to-apng

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

From source

  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
      • ffmpeg if you want to convert to APNG
      • img2webp if you want to convert to WEBP
    3. Install conan dependencies
      conan install .
      
  2. Build

    cmake CMakeLists.txt && make
    
    CMake options TGS_TO_PNG_STATIC_LINKING: enable static linking. Default value: OFF if OS is darwin; otherwise ON
    cmake -DTGS_TO_PNG_STATIC_LINKING=ON CMakeLists.txt && make
    
    cmake -DTGS_TO_PNG_STATIC_LINKING=OFF 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:
      ./bin/tgs_to_gif.sh /home/ed/Downloads/sticker.tgs
      
    • To convert to PNG:
      ./bin/tgs_to_png.sh /home/ed/Downloads/sticker.tgs
      
    • To convert to APNG:
      ./bin/tgs_to_apng.sh /home/ed/Downloads/sticker.tgs
      
    • To convert to WEBP:
      ./bin/tgs_to_webp.sh /home/ed/Downloads/sticker.tgs
      

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

CLI arguments

$ ./bin/tgs_to_gif.sh --help 
usage: ./bin/tgs_to_gif.sh [--help] [--output OUTPUT] [--height HEIGHT] [--width WIDTH] [--threads THREADS] [--fps FPS] [--quality QUALITY] 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
 --threads THREADS Number of threads to use. Default: number of CPUs
 --quality QUALITY Output quality. Default: 90

Notices

You can download .tgs files using @Stickerdownloadbot.

CLion logo.
Project is made with Jetbrains support ❤️

About

将动画 Telegram 贴纸 (*.tgs) 转换为 GIF / PNG / APNG / WEBP

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C++ 79.2%
  • Shell 9.7%
  • CMake 6.6%
  • Dockerfile 4.5%