Giter Club home page Giter Club logo

lottie-converter's Introduction

Lottie Animations (.json) and Telegram Stickers (*.tgs) to GIF/PNG/APNG/WEBP/WEBM converter

CI | Build & Test CD | Release & Push to Dockerhub


To easily transfer Telegram stickers to WhatsApp you can use Telegram Bot

๐Ÿ‘‰ https://t.me/tgtowabot ๐Ÿ‘ˆ


How to use

There are 2 options:

  • Run using Docker. One-line command, the option requires only Docker installed
  • Download and run compiled executable files. The option requires run-time dependecies installed

Using Docker

Replace with directory with Lottie animations / Telegram stickers and run:

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

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/lottie-animations:/source edasriyan/lottie-to-apng

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

Using compiled executables

  1. Install run-time dependencies. Make sure the path to them present in PATH variable:

    • gifski if you want to convert to GIF
    • ffmpeg if you want to convert to APNG or WEBM
    • img2webp if you want to convert to WEBP
  2. Download executable from releases section of this repo for your OS and arch

  3. In downloaded archive find the following executable scripts:

    • lottie_to_apng.sh
    • lottie_to_gif.sh
    • lottie_to_png.sh
    • lottie_to_webp.sh
    • lottie_to_webm.sh

    All of them have the same CLI:

    $ ./bin/lottie_to_gif.sh -h                       
    usage: ./bin/lottie_to_gif.sh [--help] [--output OUTPUT] [--height HEIGHT] [--width WIDTH] [--threads THREADS] [--fps FPS] [--quality QUALITY] path
    
    Lottie animations (.json) and Telegram stickers for Telegram (*.tgs) to animated .gif converter
    
    Positional arguments:
    path              Path to .json or .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: 
    --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
    

Build

  1. Install dependencies

    1. Make sure you have C++17 compiler, make, cmake and conan tools installed; otherwise install them
    2. Detect your conan profile
      conan profile detect
      
    3. Install conan dependencies
      conan install --build=missing .
      
  2. Invoke conan preset

    • Linux & MacOS
      cmake --preset conan-release
      
    • Windows
      cmake --preset conan-default
      
  3. Build

    cmake -DCMAKE_BUILD_TYPE=Release CMakeLists.txt && cmake --build . --config Release
    
    M1 troubleshooting 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
    ' > _deps/rlottie-src/src/vector/vdrawhelper_neon.cpp
    
  4. Convert!

    • To convert to GIF:
      ./bin/lottie_to_gif.sh /home/ed/Downloads/animation.json
      
    • To convert to PNG:
      ./bin/lottie_to_png.sh /home/ed/Downloads/animation.json
      
    • To convert to APNG:
      ./bin/lottie_to_apng.sh /home/ed/Downloads/animation.json
      
    • To convert to WEBP:
      ./bin/lottie_to_webp.sh /home/ed/Downloads/animation.json
      
    • To convert to WEBM:
      ./bin/lottie_to_webm.sh /home/ed/Downloads/animation.json
      

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

Notices

lottie-converter's People

Contributors

ed-asriyan avatar ruminateer avatar sauravdharwadkar avatar yqt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

lottie-converter's Issues

This use cache?, can I use cache for seperate sticker files?

Sticker you sent seems not to be from a sticker pack (are you send me a .tgs file?).

I'll convert it, but the next time I ask you to send me a sticker from a sticker pack, because I use caches to not convert the same sticker twice, and I can cache only stickers from sticker packs. The sticker will be converted with low priority.

Do this uses cache for telegram sticker packs (.tgs), and can I get seperate caches for seperate stickers?

[DEP0147] DeprecationWarning

Running docker built image (straight from readme) returns this warning

(node:1) [DEP0147] DeprecationWarning: In future versions of Node.js, fs.rmdir(path, { recursive: true }) will be removed. Use fs.rm(path, { recursive: true }) instead
(Use `node --trace-deprecation ...` to show where the warning was created)

Script still works, just posting as FYI

64x64 resolution?

I'm re-uploading some Telegram stickers to a service that has a 512 KiB size limit for each gif, and it would be nice to have a 64x64 resolution.

it make same copy of tgs sticker to convert to gifs in folder

i try to convert folder using master-cpp it coverts with respective names as tgs in folder .
but all converted gifs are same copy of first tgs file .

i dig a little i think problem with render.cpp / render function

auto player = rlottie::Animation::loadFromData(lottieData, "");

player variable doesnt change for rest of conversion , but output variable changes an give proper output filename
player variable get frame and do conversion stuff i thinks problem lies in player / rlottie

'ERR_MODULE_NOT_FOUND' in nodejs docker

Errors:
node:internal/errors:464
ErrorCaptureStackTrace(err);
^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/utils.js' imported from /app/cli.js
at new NodeError (node:internal/errors:371:5)
at finalizeResolution (node:internal/modules/esm/resolve:394:11)
at moduleResolve (node:internal/modules/esm/resolve:915:10)
at defaultResolve (node:internal/modules/esm/resolve:1005:11)
at ESMLoader.resolve (node:internal/modules/esm/loader:530:30)
at ESMLoader.getModuleJob (node:internal/modules/esm/loader:251:18)
at ModuleWrap. (node:internal/modules/esm/module_job:79:40)
at link (node:internal/modules/esm/module_job:78:36) {
code: 'ERR_MODULE_NOT_FOUND'
}

Node.js v17.3.0

Error: WebSocket is not open: readyState 3 (CLOSED)

node version: v17.1.0
npm version: 8.3.1

I am trying to run this converter, but on every attempt I get this error and nothing is converted.

Converting D:\Telegram Desktop\Animated\ytrfAnimatedSticker.tgs...
Error: WebSocket is not open: readyState 3 (CLOSED)
    at WebSocket.send (D:\tgs-to-gif\node_modules\ws\lib\websocket.js:329:19)
    at WebSocketTransport.send (D:\tgs-to-gif\node_modules\puppeteer\lib\WebSocketTransport.js:60:14)
    at Connection._rawSend (D:\tgs-to-gif\node_modules\puppeteer\lib\Connection.js:86:21)
    at Connection.send (D:\tgs-to-gif\node_modules\puppeteer\lib\Connection.js:72:21)
    at Browser._createPageInContext (D:\tgs-to-gif\node_modules\puppeteer\lib\Browser.js:174:47)
    at BrowserContext.newPage (D:\tgs-to-gif\node_modules\puppeteer\lib\Browser.js:367:26)
    at Browser.newPage (D:\tgs-to-gif\node_modules\puppeteer\lib\Browser.js:166:33)
    at Browser.<anonymous> (D:\tgs-to-gif\node_modules\puppeteer\lib\helper.js:112:23)
    at default (file:///D:/tgs-to-gif/render.js:81:32)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
  -- ASYNC --
    at Browser.<anonymous> (D:\tgs-to-gif\node_modules\puppeteer\lib\helper.js:111:15)
    at default (file:///D:/tgs-to-gif/render.js:81:32)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async file:///D:/tgs-to-gif/index.js:55:50
    at async file:///D:/tgs-to-gif/index.js:37:20
    at async convertFiles (file:///D:/tgs-to-gif/cli.js:12:7)
    at async main (file:///D:/tgs-to-gif/cli.js:44:3)
    ```

Update queued request in Telegram Bot

Hi.
After using your bot for several months, today I ended up with a "Queued (505)..." message. This was somehow exciting to see people are using your bot, but it was confusing since I couldn't have any ideas on when this queue will end and the gif will be sent. Honestly, this caused me to send my sticker again to check if this works now. I believe the current behavior causes other people do the same, and may impose an excess load on your backend servers.

It would be good if the bot can periodically inform people of their queue status. For example, iterating the queue every 5 seconds and update that "Queued (x)..." message (if x is really the position in queue!).

Create releases

Please create a release tarball of the c++ version so those that can't/don't want to git clone can use tgs-to-gif. Thank you!

Request Code

so you make telegram animated stickers to gif but is there any Bot who will convert gif to telegram animated stickers
or give me Code or library to do it

Converted GIF's Slowed Down

Hello. Your Telegram bot and Docker container are very useful. I recently tried it out and there's an odd behaviour with the converted GIFs - the "animation" is slowed down when they are inserted in Telegram or other messaging app (like Apple Messages). Do you know why that is? (Is it because the file size of the convertged GIF is much larger than the original tgs format)

Thanks,
Adit

request: tgs to apng for high quality frames

Hello. I want to request freature to convert tgs to apng animation with best quality than gif. Because now resulted gif has lowest qualty than original tgs sticker and has pixelized borders. Or just zip archive with each frame as png file format if apng is a difficult realization.
Thanks

does not work when file name contains '('

filename: AnimatedSticker (1).tgs

[kj@uno tgs-to-gif]$ node cli.js /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker (1).tgs
bash: syntax error near unexpected token `('

[kj@uno tgs-to-gif]$
[kj@uno tgs-to-gif]$
[kj@uno tgs-to-gif]$
[kj@uno tgs-to-gif]$
[kj@uno tgs-to-gif]$ node cli.js /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker\ (1).tgs
Converting /home/kj/Downloads/Telegram Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker (1).tgs...
โœ” Loading browser
โœ” Rendering 180 frames
โ ‹ Generating GIF with GifskiError: Command failed: /bin/sh -c gifski -o /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker\ (1).tgs.gif --fps 50 --quality 80 --quiet /tmp/96defc45f1ea964839e07576ca6986c7/frame-.png
/bin/sh: -c: line 1: syntax error near unexpected token (' /bin/sh: -c: line 1: gifski -o /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker\ (1).tgs.gif --fps 50 --quality 80 --quiet /tmp/96defc45f1ea964839e07576ca6986c7/frame-
.png'

at makeError (/home/kj/Code/node/tgs-to-gif/node_modules/execa/index.js:174:9)
at /home/kj/Code/node/tgs-to-gif/node_modules/execa/index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async module.exports (/home/kj/Code/node/tgs-to-gif/node_modules/puppeteer-lottie/index.js:422:5)
at async convertFile (/home/kj/Code/node/tgs-to-gif/index.js:31:3)
at async convertFiles (/home/kj/Code/node/tgs-to-gif/cli.js:12:7)
at async main (/home/kj/Code/node/tgs-to-gif/cli.js:46:3) {

code: 2,
stdout: '',
stderr: "/bin/sh: -c: line 1: syntax error near unexpected token ('\n" + "/bin/sh: -c: line 1: gifski -o /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker\ (1).tgs.gif --fps 50 --quality 80 --quiet /tmp/96defc45f1ea964839e07576ca6986c7/frame-.png'\n",
failed: true,
signal: null,
cmd: '/bin/sh -c gifski -o /home/kj/Downloads/Telegram\ Desktop/DataExport_2021-11-10/chats/chat_4/stickers/AnimatedSticker\ (1).tgs.gif --fps 50 --quality 80 --quiet /tmp/96defc45f1ea964839e07576ca6986c7/frame-
.png',
timedOut: false,
killed: false
}
โ ธ Generating GIF with Gifski

it give error when i tried to use whole folder

./tgs_to_gif ./webp

terminate called after throwing an instance of 'std::__ios_failure'
what(): basic_filebuf::xsgetn error reading the file: Is a directory
[1] 22537 abort (core dumped) tgs_to_gif ./webp

Error while converting

I got error while converting.
Did I miss something?

littlebear@littlebear:~/tgs-to-gif$ npm start .

> [email protected] start /home/littlebear/tgs-to-gif
> node index.js "."

Converting 2_1360886329340072453.tgs...
events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: incorrect header check
    at Zlib.zlibOnError [as onerror] (zlib.js:180:17)
Emitted 'error' event on Gunzip instance at:
    at errorOrDestroy (internal/streams/destroy.js:128:12)
    at Gunzip.onerror (_stream_readable.js:764:9)
    at Gunzip.emit (events.js:321:20)
    at Zlib.zlibOnError [as onerror] (zlib.js:183:8) {
  errno: -3,
  code: 'Z_DATA_ERROR'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node index.js "."`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/littlebear/.npm/_logs/2020-01-12T02_56_26_059Z-debug.log

GIF Loopcount

Not really an issue, just wondering if can we made the loopcount more than 1, or as an argument passed on the docker for example.

Regards

Error

Why do I always get this on the iOS stickers they work some times then I get this error thing the other times Queued (2907) ๐Ÿค”๐Ÿ’š

Jam sticker conversion request returns empty zip files

Good morning, Ed.

I thought you might like to know that โ™กโ™กโ™ก @tgstogifbot โ™กโ™กโ™ก returns empty zip files upon requests to convert stickers from Jam, aka SweetJam. I've seen the same behavior from two different stickers, two different telegram clients, on two different OSes.

Sticker pack: https://t.me/addstickers/SweetJam
Stickers tried: ๐Ÿ‘‹ and ๐Ÿ‘
Returned zip: SweetJam-512px.zip
Screen shot from Macbook pro:

  • Screen_Shot_2021-01-22_at_8 14 47_AM_70

Telegram macOS Client v2.5.1:

  • Telegram Desktop Client Version

macOS Big Sur v11.0.1:

  • Big Sur

Screenshot from iPhone Xs Max:

  • Screenshot 2021-01-22 at 8.31.35 AM

Telegram iOS Client v7.3.1:

  • Telegram iOS Client Version

iOS v14.3:

  • iOS version

Cheers,
Phil

Empty Zip Folder

I sent stickers from the Bubo the Scarfcat pack (and the whole pack) to it and it only sends back empty zip files. I tried with one from a different pack and it worked fine.
Screenshot_20210110-214754_Telegram

Docker build

Hi,
I am using Windows 10 with cmd or WSL and docker for windows.
I tried to build the docker image with the command in the readme docker build -t tgs-to-gif .

I get the error logs:

Step 10/15 : RUN npm ci
 ---> Running in a68b9cca070e
npm ERR! code ENOENT
npm ERR! syscall spawn git
npm ERR! path git
npm ERR! errno ENOENT
npm ERR! enoent Error while executing:
npm ERR! enoent undefined ls-remote -h -t https://[email protected]/ed-asriyan/puppeteer-lottie.git
npm ERR! enoent
npm ERR! enoent
npm ERR! enoent spawn git ENOENT
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

I tried this with WSL and Ubuntu bash and with CMD from Windows10 directly and got the same output

Any Idea what I am doing wrong?

Transparent background?

Hi,
I've just tried the bot and it's great!

One question though: how about adding an optional parameter for transparent background to the gif?

Thanks

conversion error

Using node cli.js 1.tgs
Returns an error.
How to fix it,

(node:3718) DeprecationWarning: _ActionsContainer.addArgument() is renamed to _ActionsContainer.add_argument()
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3718) DeprecationWarning: ArgumentParser.parseArgs() is renamed to ArgumentParser.parse_args()
/home/admin/web/swedart.ru/public_html/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193
            reject(new Error([
                   ^

Error: Failed to launch the browser process!
[0329/002301.725900:ERROR:zygote_host_impl_linux.cc(90)] Running as root without --no-sandbox is not supported. See https://crbug.com/638180.


TROUBLESHOOTING: https://github.com/puppeteer/puppeteer/blob/main/docs/troubleshooting.md

    at onClose (/home/admin/web/swedart.ru/public_html/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:193:20)
    at Interface.<anonymous> (/home/admin/web/swedart.ru/public_html/node_modules/puppeteer/lib/cjs/puppeteer/node/BrowserRunner.js:183:68)
    at Interface.emit (node:events:381:22)
    at Interface.close (node:readline:514:8)
    at Socket.onend (node:readline:248:10)
    at Socket.emit (node:events:381:22)
    at endReadableNT (node:internal/streams/readable:1307:12)
    at processTicksAndRejections (node:internal/process/task_queues:81:21)

white screen frame

I found that the resulting gif loops back to the beginning after playback will have a white screen frame

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.