#!/bin/bash #./concave.sh $input.jpg ##output to $outfile (a2.jpg) #fpath=$(basename "${1}");outfile="${fpath%.*}"-c.png; bc=none outfile="a2.jpg" #a2.png bc=white #none distort=0.25 #.2 trimpad="-fuzz 0.1 -trim +repage" distort=`convert xc: -format "%[fx:-$distort]" info:` a=`convert xc: -format "%[fx:1+$distort]" info:` b=`convert xc: -format "%[fx:-$distort]" info:` input="$1" tmpA0="./texteffect_00_$$.mpc" convert -quality 95 $input $tmpA0 width=`identify -format %w $tmpA0` height=`identify -format %h $tmpA0` w2=`convert xc: -format "%[fx:$width/2]" info:` h2=`convert xc: -format "%[fx:$height/2]" info:` xc=$w2 yc=$h2 vp="-virtual-pixel background" convert $tmpA0 $vp -fuzz 0.3% -trim +repage $tmpA0 ww=`convert $tmpA0 -format "%w" info:` hh=`convert $tmpA0 -format "%h" info:` halfw=`convert xc: -format "%[fx:$ww/2]" info:` b=`convert xc: -format "%[fx:$b*(2*min($ww,$hh)/(1.3*($ww+$hh)))^2]" info:` fac=1.5 #1.25 newhh=`convert xc: -format "%[fx:$hh*$fac]" info:` convert $tmpA0 $vp -resize x${newhh}! -background $bc -filter lanczos \ -gravity north -extent ${ww}x${newhh} \ -distort barrelinverse "0 0 0 1 0 $b 0 $a $halfw 0" \ $trimpad $tmpA0 convert $tmpA0 "$outfile" rm $tmpA0 *.cache exit