-
-
Save alukach/3088592 to your computer and use it in GitHub Desktop.
Convert a .mpo file to an animated gif
This file contains hidden or 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/sh | |
# mpo2gif | |
# convert all .mpo files in a directory to a animation gif. | |
# Source: https://gist.github.com/878450 | |
# this idea is from http://www.imagemagick.org/discourse-server/viewtopic.php?f=1&t=16275 | |
# this script requires exiftool and imagemagick. | |
for file in *.[Mm][Pp][Oo0]; do | |
rjpg=/tmp/$$_r.jpg | |
ljpg=/tmp/$$_l.jpg | |
#Remove spaces from filename | |
if [[ "$file" != "${file// /_}" ]] | |
then | |
echo Converting \'$file\' to \'${file// /_}\' | |
mv "$file" "${file// /_}" | |
fi | |
file=${file// /_} | |
echo $file | |
#Change filename extension to .gif | |
gif=${file%.*}.gif | |
#Create gif | |
exiftool -trailer:all= $file -o $rjpg | |
exiftool $file -mpimage2 -b > $ljpg | |
convert -loop 0 -delay 15 $ljpg -resize 360000@ -delay 15 $rjpg -resize 360000@ $gif #-delay 10 seems about right, 15 is a bit calmer | |
rm $rjpg $ljpg | |
#Make directories | |
if [[ ! -e originals ]] | |
then | |
mkdir originals | |
fi | |
if [[ ! -e gifs ]] | |
then | |
mkdir gifs | |
fi | |
#Move files | |
mv "$file" originals/ | |
mv "$gif" gifs/ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment