display Transparent GIF on LINE Sticker-like
ShellScript
#/usr/bin/zsh -eu
GIFD=$(basename "$(pwd)")
mkdir "${GIFD} GIF"
yes |
for i in *.png
do
FILENAME=${i%.*}
mkdir ${FILENAME}
cp $i ${FILENAME}/1.png
cp $i ${FILENAME}/2.png
cd ${FILENAME}
ffmpeg -i 1.png -vf palettegen palette.png && ffmpeg -f image2 -r 1 -i %d.png -i palette.png -filter_complex paletteuse "../${GIFD} GIF/${FILENAME}.gif"
cd -
rm -r ${FILENAME}
done
Python
#/usr/bin/env python
import os
import glob
import shutil
import subprocess
os.makedirs('./GIF')
pngtati = glob.glob("*.png")
for f in pngtati:
filename = os.path.splitext(os.path.basename(f))[0]
os.makedirs('kari')
shutil.copyfile(f, "kari/1.png")
shutil.copyfile(f, "kari/2.png")
os.chdir('./kari')
subprocess.call('ffmpeg -f image2 -r 1 -i %d.png -filter_complex "split [a][b];[a] palettegen [p];[b][p] paletteuse" "../GIF/' + filename + '.gif"', shell=True)
os.chdir('..')
shutil.rmtree('kari')
How to use
First, prepare background transparent images.
cd
to the directory where the transparent images you want to display like stickers are located
and run this script.
Example of usage