Skip to content

Commit

Permalink
fixed Automator and Service by using absolute paths to file commands
Browse files Browse the repository at this point in the history
Thanks to Xavier Molina-Schenk for helping me debug!
  • Loading branch information
minimaxir committed Aug 17, 2015
1 parent c758a49 commit 41ad925
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 14 deletions.
Binary file modified Convert Video to GIF App.zip
Binary file not shown.
Binary file modified Convert Video to GIF.zip
Binary file not shown.
10 changes: 5 additions & 5 deletions tests/test.sh
Expand Up @@ -2,7 +2,7 @@ rm test_result.txt
touch test_result.txt

echo "Programs installed:" >> test_result.txt
brew ls --versions mplayer ImageMagick gifsicle >> test_result.txt
/usr/local/bin/brew ls --versions mplayer ImageMagick gifsicle >> test_result.txt

touch ~/.bash_profile
source ~/.bash_profile
Expand All @@ -23,7 +23,7 @@ do

cd "$dir"

video_properties=$(mplayer -really-quiet -ao null -vo null -identify -frames 0 "$f")
video_properties=$(/usr/local/bin/mplayer -really-quiet -ao null -vo null -identify -frames 0 "$f")
#echo "Parsed Video Properties.\n" >> test_result.txt

video_width=$(echo $video_properties | sed -e 's/.*\ID_VIDEO_WIDTH=\([0-9]*\).*/\1/')
Expand Down Expand Up @@ -54,19 +54,19 @@ do
final_height=$video_height
fi

mplayer -ao null -vo png:z=1:outdir=.temp -vf scale=$final_width:$final_height "$f"
/usr/local/bin/mplayer -ao null -vo png:z=1:outdir=.temp -vf scale=$final_width:$final_height "$f"

num_renders=$(ls -l .temp | wc -l)
#echo "mplayer renders successful." >> test_result.txt
echo "mplayer number of video frames: $num_renders.\n" >> test_result.txt

convert +repage -fuzz 1.6% -delay 1.7 -loop 0 .temp/*.png -layers OptimizePlus -layers OptimizeTransparency .temp.gif
/usr/local/bin/convert +repage -fuzz 1.6% -delay 1.7 -loop 0 .temp/*.png -layers OptimizePlus -layers OptimizeTransparency .temp.gif

file_size_imagemagick=$(wc -c .temp.gif)
#echo "ImageMagick convert successful." >> test_result.txt
echo "ImageMagick convert file size: $file_size_imagemagick\n" >> test_result.txt

gifsicle -O3 --colors 256 .temp.gif > "${name%.*}.gif"
/usr/local/bin/gifsicle -O3 --colors 256 .temp.gif > "${name%.*}.gif"

file_size_gifsicle=$(wc -c "${name%.*}.gif")
#echo "gifsicle optimization successful." >> test_result.txt
Expand Down
16 changes: 7 additions & 9 deletions video_to_gif_osx.sh
@@ -1,6 +1,4 @@
source ~/.bash_profile

for f in "$@"
for f
do

# Change this value to increase maximum size
Expand All @@ -11,13 +9,13 @@ do

cd "$dir"

video_properties=$(mplayer -really-quiet -ao null -vo null -identify -frames 0 "$f")
video_properties=$(/usr/local/bin/mplayer -really-quiet -ao null -vo null -identify -frames 0 "$f")

video_width=$(echo $video_properties | sed -e 's/.*\ID_VIDEO_WIDTH=\([0-9]*\).*/\1/')
video_height=$(echo $video_properties | sed -e 's/.*\ID_VIDEO_HEIGHT=\([0-9]*\).*/\1/')
aspect_ratio=$(echo "$video_width $video_height" | awk '{printf "%.5f", $1/$2}')

# shrink larger dimension to GIF_MAX_SIZE;
# shrink larger dimension to GIF_MAX_SIZE;
if [ $video_height -lt $video_width ]
then
final_width=$GIF_MAX_SIZE
Expand All @@ -26,19 +24,19 @@ do
final_height=$GIF_MAX_SIZE
final_width=$(echo "$final_height $aspect_ratio" | awk '{printf "%3.0f", $1/(1/$2)}')
fi

# Don't change dimensions if both are below GIF_MAX_SIZE
if [$video_width -lt $GIF_MAX_SIZE] && [$video_height -lt $GIF_MAX_SIZE]
then
final_width=$video_width
final_height=$video_height
fi

mplayer -ao null -vo png:z=1:outdir=.temp -vf scale=$final_width:$final_height "$f"
/usr/local/bin/mplayer -ao null -vo png:z=1:outdir=.temp -vf scale=$final_width:$final_height "$f"

convert +repage -fuzz 1.6% -delay 1.7 -loop 0 .temp/*.png -layers OptimizePlus -layers OptimizeTransparency .temp.gif
/usr/local/bin/convert +repage -fuzz 1.6% -delay 1.7 -loop 0 .temp/*.png -layers OptimizePlus -layers OptimizeTransparency .temp.gif

gifsicle -O3 --colors 256 .temp.gif > "${name%.*}.gif"
/usr/local/bin/gifsicle -O3 --colors 256 .temp.gif > "${name%.*}.gif"

# Cleanup
rm -rf .temp
Expand Down

0 comments on commit 41ad925

Please sign in to comment.