All pastes #935943 Raw Edit

Miscellany

public shellscript v1 · immutable
·published 2008-03-10 00:46 UTC
rendered paste body
mk_polaroid_stack(){    local stackfiles=( "$@" )    local CONVERT="convert -quality 01"    # this assignment not used in script, just for standalone demo purposes    WORK_DIR=`pwd`    for i in ${!stackfiles[@]}; do        # Use a 'random' angle        local angle=$((RANDOM %45 +1))        local angle=$(( (angle / 2) * 2 ))        # thumbnail to 120x80 (just dvd for now) TODO get rid of magic numbers        $CONVERT "${stackfiles[i]}" -background none -thumbnail 120x80\! \        -bordercolor '#EAEAEA' -shave 4x4 +repage -border 4x4 \        -rotate $angle  "$WORK_DIR/tnail${i%.*}.png"        stack_files[i]=$WORK_DIR/tnail${i%.*}.png        # Composite the polaroid over the canvas        # get 'random' coordinates        local rand_xloc=$((RANDOM %400 +80))        local rand_yloc=$((RANDOM %200 +50))        local rand_loc="+${rand_xloc}+${rand_yloc}"        local img_page[i]="-page $rand_loc"    done    for i in ${!stack_files[@]}; do        local image_page=( "${image_page[@]}" ${img_page[i]} "${stack_files[i]}" )    done    $CONVERT -background none -size 640x480 xc:none \    "${image_page[@]}" -mosaic -trim +repage miff:- |    $CONVERT -size 720x480 xc:black -background none \    -gravity Center -geometry +0+0 - -composite \    "$WORK_DIR/image_stack.png"}