ed-asriyan / lottie-converter

Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to GIF / PNG / APNG / WEBP / WEBM
https://t.me/tgtowabot
MIT License
795 stars 72 forks source link

Question: How to convert only single file in dir via docker? #90

Closed AlexMercier closed 5 months ago

AlexMercier commented 5 months ago

Hi! Now converting using docker will convert all files in directory. How can I run Docker command to convert only one file in dir?

ed-asriyan commented 5 months ago

Hi, yes, you can do this by mounting input and output files:

# fill variables:
INPUT_FILE= # input file with extension lottie, json or tgs 
OUTPUT_FILE= # output file path with extension gif, apng or webp

# --- script ---
INPUT_EXT="${INPUT_FILE##*.}"
OUTPUT_EXT="${OUTPUT_FILE##*.}"

# create empty output file to mount it in container
touch $OUTPUT_FILE

# convert
docker run --rm -v $INPUT_FILE:/source/animation.$INPUT_EXT -v $OUTPUT_FILE:/source/animation.$INPUT_EXT.$OUTPUT_EXT edasriyan/lottie-to-$OUTPUT_EXT