#! /bin/bash # Last edited on 2004-01-09 13:09:21 by stolfi cmd="${0##*/}" usage="${cmd} DIR IMG... > MOVIE.gif" # Reads the images "{IMG}.jpg" from directory {DIR}. # Converts them to 640x480 pixels, adjusts lighting, # and turns them into a GIF movie that is written to stdout. if [ $# -lt 2 ]; then echo "usage: ${usage}"; exit 1; fi dir="$1"; shift; imgs=( $* ) temp="/tmp/$$" bp=1 wp=5 n=100 frames=( ) for img in ${imgs[@]} ; do frame=${temp}-${n}.ppm convert ${dir}/${img}.jpg -geometry 'x480' PPM:- \ | ppmtorgb3 for chn in red grn blu ; do cat noname.${chn} \ | pgmnorm -bpercent ${bp} -wpercent ${wp} \ | pnmgamma 1.80 \ | pnmdepth 255 \ > ${temp}-${chn}.pgm done rgb3toppm ${temp}-{red,grn,blu}.pgm \ > ${frame} display -title '%f' ${frame} ${temp}-{red,grn,blu}.pgm & frames=( ${frames[@]} ${frame} ) n=$((n + 1)) done convert ${frames[@]} -delay 50 -loop 20 ${temp}-m.gif display -delay 1 ${temp}-m.gif cat ${temp}-m.gif /bin/rm -f noname.{red,grn,blu} ${temp}-*