Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ################################################################################
- # screenshots.sh
- # - ImageMagick must be installed (http://wiki.ubuntuusers.de/ImageMagick).
- # - Makes a gif image from screenshots (e.g. for ZDS).
- # - Number of ZDS will be calculated.
- # V1.1.0
- #
- # Changelog:
- # V1.0.0
- # - Initial version
- #
- # V1.1.0
- # - Bugfix ZDS number
- # - Input and output cleanup
- #
- #
- ################################################################################
- # Init
- out_count=0
- screenshot_temp=screenshot_temp_
- firstzds=20070901
- delay_time=250 # 1/100 seconds
- gamma=1.35
- # Number of images
- images_count=$(find *.png | wc -l)
- # Calculating ZDS number
- tmp=$( date -d $firstzds +%s )
- zds=$(( (`date +%s` - $tmp) / 86400 / 7 ))
- ################################################################################
- # Script start
- echo ""
- echo ""
- echo "Screenshots to gif"
- echo "~~~~~~~~~~~~~~~~~~"
- echo ""
- # Checking ImageMagick
- if which convert > /dev/null; then
- echo "ImageMagick found"
- else
- echo "ImageMagick not installed!"
- echo ""
- exit
- fi
- # Checking number of images
- if [ $images_count == 0 ]; then
- echo "No images found!"
- echo ""
- exit
- else if [ $images_count == 1 ]; then
- echo "1 image found, nothing to do!"
- echo ""
- exit
- else
- echo $images_count" images found"
- fi
- fi
- # Enter resolution
- while [ TRUE ]; do
- echo ""
- echo "1) 4:3 (800x600)"
- echo "2) 16:9 (928x522)"
- echo -n "Resolution: "
- read Select
- case $Select in
- 1)
- Resolution=800
- break
- ;;
- 2)
- Resolution=928
- break
- ;;
- # default: loop
- esac
- done
- # Enter output filename
- echo ""
- echo -n "File name (no extension, Enter = 'zds-"$zds"_screenshots.gif'): "
- read outputfile
- if [ "$outputfile" = "" ]; then
- outputfile="zds-"$zds"_screenshots.gif"
- else
- outputfile=$outputfile".gif"
- fi
- # Get start time
- starttime=$(date +%s)
- # Creat temporary bmp files in 24 bit
- echo ""
- echo -n "Converting to 24 bit and resizing: "
- for i in *.png
- do
- let "out_count++"
- #echo "Input: $i -> Output: $screenshot_temp$(printf '%04d' "$out_count").bmp" # debug
- let "percentage = (out_count * 100) / $images_count"
- printf "%3d%%" $percentage
- nice -n 6 convert $i -resize "$Resolution"x -gamma $gamma -depth 24 $screenshot_temp$(printf '%04d' "$out_count").bmp
- echo -ne '\b\b\b\b'
- done
- echo -ne '\b'
- echo ""
- # Creat gif
- echo -n "Creating '$outputfile'..."
- nice -n 6 convert -type optimize -delay $delay_time -loop 0 $screenshot_temp*.bmp "$outputfile"
- echo "done"
- # Delete bmp files
- echo -n "Cleaning temporary files..."
- rm $screenshot_temp*.bmp
- echo "done"
- # End time
- timeend=$(date +%s)
- let "timediff = $timeend - $starttime"
- echo "Time: $timediff seconds"
- echo ""
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement