But it is not working

I converted it to php. I get output gif file which has no animation.
I tried to run it as shell script just by coping your script. I got errors.
I defined the variables however in php and shell scripts.
PHP OUTPUT : output.gif without effects. Just the first image is displayed all the time.
Shell Script Output : Error
convert: unable to open image `tmp0.gif': No such file or directory @ blob.c/OpenBlob/2480.
convert: no decode delegate for this image format `/tmp/magick-XXo6BeS8' @ constitute.c/ReadImage/503.
convert: missing an image filename `tmp0.gif' @ convert.c/ConvertImageCommand/2800.
convert: unable to open image `tmp0.gif': No such file or directory @ blob.c/OpenBlob/2480.
convert: option requires an argument `-loop' @ convert.c/ConvertImageCommand/1775.
Code: Select all
frames=20
delay=20
i=1
outfile = "x.gif"
infile1 = "1.jpg"
infile2 = "2.jpg"
maskfile = "mask.jpg"
frames=$((frames-1))
while [ $i -le $frames ]; do
aa=`/usr/convert xc: -format "%[fx:100*$i/$frames]" info:`
/usr/convert $infile1 tmp0.gif
/usr/convert $infile1 $infile2 \( $maskfile -evaluate add $aa% \) -composite miff:- |\
/usr/convert -delay $delay tmp0.gif - tmp0.gif
i=$((i+1))
done
/usr/convert tmp0.gif -loop 0 $outfile