try the following for a fixed number of composites
convert stamp_pic.png black_canvas.png \
\( -clone 1 -clone 0 -compose screen -geometry +100+100 -composite \) -delete 1 \
\( -clone 1 -clone 0 -compose screen -geometry +200+200 -composite \) -delete 1 \
\( -clone 1 -clone 0 -compose screen -geometry +300+300 -composite \) -delete 1 \
-delete 0 black_canvas1.png
or
convert \( stamp_pic.png -write mpr:image \) black_canvas.png \
\( -clone 1 mpr:image -compose screen -geometry +100+100 -composite \) -delete 1 \
\( -clone 1 mpr:image -compose screen -geometry +200+200 -composite \) -delete 1 \
\( -clone 1 mpr:image -compose screen -geometry +300+300 -composite \) -delete 1 \
-delete 0 black_canvas2.png
However, in PHP, you can make a string with all the composite lines that you need to do (if it is not too long for PHP) and then bring the string in. For example,
str="\( -clone 1 mpr:image -compose screen -geometry +100+100 -composite \) -delete 1 \
\( -clone 1 mpr:image -compose screen -geometry +200+200 -composite \) -delete 1 \
\( -clone 1 mpr:image -compose screen -geometry +300+300 -composite \) -delete 1 \"
convert \( stamp_pic.png -write mpr:image \) black_canvas.png \
$str -delete 0 black_canvas2.png
You can create the string in a PHP loop also.
You can also do the following (in bash Unix terminal) with a memory mapped disk file. (You will have to convert to PHP equivalent). This may speed your loops up.
tmp1A="./stamp_1_$$.mpc"
tmp1B="./stamp_1_$$.cache"
tmp2A="./stamp_2_$$.mpc"
tmp2B="./stamp_2_$$.cache"
trap "rm -f $tmp1A $tmp1B $tmp2A $tmp2B; exit 0" 0
trap "rm -f $tmp1A $tmp1B $tmp2A $tmp2B; exit 1" 1 2 3 15
convert stamp_pic.png $tmp1A
convert black_canvas.png $tmp2A
i=1
num=3
geom1="+100+100"
geom2="+200+200"
geom3="+300+300"
while [ $i -le $num ]; do
eval convert $tmp2A $tmp1A -compose screen -geometry \$geom$i -composite $tmp2A
i=`expr $i + 1`
done
convert $tmp2A black_canvas3.png
exit 0
But at least you can do the looping over any number of locations.
see
http://www.imagemagick.org/Usage/files/#mpc
http://www.imagemagick.org/Usage/files/#mpr
http://www.imagemagick.org/Usage/basics/#image_seq