Advertisement
metalx1000

Create a GIF slide show with imagemagick

Feb 15th, 2012
456
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.36 KB | None | 0 0
  1. #!/bin/bash
  2. #creates a fading GIF slide show of all images in a dir
  3. #created by Kris Occhipinti
  4. #Wed Feb 15th 2012
  5. #http://filmsbykris.com
  6. #GPLv3 http://www.gnu.org/licenses/gpl-3.0.html
  7. random=$RANDOM
  8. rm -fr /tmp/123
  9. mkdir /tmp/123
  10. mkdir /tmp/$random
  11. clear
  12. x=0
  13. let y=100
  14.  
  15. for img in $(ls *.jpg *.png *.bmp )
  16. do
  17.  if [ "$x" = "0" ]
  18.  then
  19.    x="$img"
  20.    z="$img"
  21.  else
  22.   echo -n "Creating Fade Images..."
  23.   for i in {000..100..5}
  24.   do
  25.     composite -dissolve $i "$img" "$x" -alpha Set /tmp/123/$i.png
  26.     echo -n "."
  27.   done
  28.   x="$img"
  29.  
  30.   echo ""
  31.  
  32.   #Hold Still image for 10 frames
  33.   for p in {101..111}
  34.   do
  35.       cp /tmp/123/100.png /tmp/123/$p.png
  36.   done
  37.  
  38.   echo "Combining Images into GIF File /tmp/$random/fade_$y.gif..."
  39.   convert -delay 20 -loop 0 /tmp/123/*.png /tmp/$random/fade_$y.gif
  40.   let y+=1
  41.   rm -fr /tmp/123/*
  42.  fi
  43. done
  44.  
  45. echo -n "Creating Final Loop Back..."
  46. for i in {000..100..5}
  47. do
  48.     composite -dissolve $i "$z" "$img" -alpha Set /tmp/123/$i.png
  49.     echo -n "."
  50. done
  51.  
  52. #Hold Still image for 10 frames
  53. for p in {101..111}
  54. do
  55.     cp /tmp/123/100.png /tmp/123/$p.png
  56. done
  57.  
  58. convert -delay 20 -loop 0 /tmp/123/*.png /tmp/$random/fade_$y.gif
  59. echo ""
  60. convert /tmp/$random/*.gif fade_$random.gif
  61. echo "File fade_$random.gif Created."
  62.  
  63. echo "Cleaning up TMP DIR..."
  64. rm -fr /tmp/$random/
  65.  
  66. xdg-open "fade_$random.gif"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement