#!/bin/sh # # squeeze - squeeze an image using seam carving # # $Id$ # Some alpha composition is used to crop the result to the original size. # # Modified from the original at # # http://www.imagemagick.org/Usage/resize/ # default values: bc=black # border color bf=black # border fill color bw=1 # border size in pixels td=42 # total duration in seconds sw=1 # number of pixels to reduce by in each step pg=1 # percentage to shrink image to # overrides from the environment: : ${bc=SQUEEZE_BORDER_COLOR} : ${bf=SQUEEZE_BORDER_COLOR} : ${bf=SQUEEZE_BORDER_FILL_COLOR} : ${bw=SQUEEZE_BORDER_WIDTH} : ${td=SQUEEZE_DURATION} : ${sw=SQUEEZE_STEP_WIDTH} : ${pg=SQUEEZE_PERCENTAGE} AnimatedSeamCarve() { { echo -delay $td "$1" -resize 50% -trim +repage -bordercolor $bc echo \( +clone -border ${bw}x${bw} -fill $bf -colorize 100% \) echo -gravity center for i in `seq 100 -$sw $pg ;`; do echo \( -clone 0 -liquid-rescale ${i}x${i}%\! echo -border ${bw}x${bw} -clone 1 +swap -composite \) done # remove source images echo -delete 0,1 # duplicate frames to reverse echo \( -clone -2-1 \) # write out animation echo -layers Optimize -loop 0 "$2" } | xargs convert } for f in "$@" do AnimatedSeamCarve "$f" "$f".gif done