Created
September 28, 2018 06:26
-
-
Save cattaka/25a4320b785fe6092c40c34eb8038f8b to your computer and use it in GitHub Desktop.
Convert GIF files in ODP to APNG to upload Google Slide
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" -o -z "$2" ]; then | |
echo "Usage: $0 <from_file> <to_file>" | |
exit | |
fi | |
FROM_FILE=$1 | |
TO_FILE=$2 | |
WORK_DIR=_tmp | |
WORK_FILE=_tmp.png | |
FFPMPEG_EX="-r 20 -plays 0 -loglevel quiet" | |
rm -rf ${WORK_DIR} | |
mkdir ${WORK_DIR} | |
unzip ${FROM_FILE} -d ${WORK_DIR} | |
for gif_file in `ls ${WORK_DIR}/Pictures/*`; do | |
mime=`file -bi $gif_file` | |
if [[ $mime = *"image/gif"* ]]; then | |
echo "Converting: $mime : $gif_file" | |
ffmpeg -y -i $gif_file -f apng $FFPMPEG_EX $WORK_FILE | |
cp $WORK_FILE $gif_file | |
else | |
echo "Skip: $mime : $gif_file" | |
fi | |
done | |
cd $WORK_DIR | |
rm ../$TO_FILE | |
zip -r ../$TO_FILE * | |
cd .. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment