Yep. Did that. Thanks though.
Actually stepped through it with someone with MUCH more bash scripting experience than me and got it to work.
Needed a couple changes but so far so good.
For those playing along at home, this is what it took:
Code: Select all
#1/bin/bash
infile="lena.jpg"
amplitude=10
row=128
ww=`convert -ping "$infile" -format "%w" info:`
hh=`convert -ping "$infile" -format "%h" info:`
wm1=$((ww-1))
hm1=$((hh-1))
coords=`convert -size 1x256 gradient: -rotate 90 -function sinusoid "1,180,0.5,0.5" txt:- |\
sed -n 's/^\([^,]*\),.*: [(]\([^,]*\).*$/\1,\2/p'`
#echo $coords
xArr=(`echo "$coords" | cut -d, -f1`)
yArr=(`echo "$coords" | cut -d, -f2`)
len=${#xArr[*]}
for ((i=0; i<len; i++))
do
y="${yArr[$i]}"
yy=$(echo "scale=6; $amplitude*${y%%%}*.01*2+$row")
yy=$(echo "${yy}" | bc)
# yy=`echo "scale=6; $amplitude*${yArr[$i]}*2/$qrange+$row" | bc`
coordArr[$i]="${xArr[$i]},$yy"
done
coords="${coordArr[*]} $wm1,$hm1 0,$hm1"
echo $coords
convert "$infile" \( +clone -fill white -colorize 100 -fill black -draw "polygon $coords" -alpha off \) -compose copy_opacity -composite lena_sine_crop2.png
qrange was throwing us. As well as the % sign being piped into bc.