文法的には簡単でこんな感じになります。
rectangle([x],[y],[width],[height]);
rectangleは描画なのでDrawします。Sample
<?php
$imagefile = “./images/sample.jpg”;
# 画像の読み込み
$base = new Imagick($imagefile);
# 四角形を描画
$idraw = new ImagickDraw();
$idraw->setFillColor(“#ffffff”); # 描画色
$idraw->setFillOpacity(0.3); # 透明度
$x = rand(0,1280);
$y = rand(0,980);
$width = rand(0,1280);
$height = rand(0,980);
$idraw->rectangle($x,$y,$width,$height); # 四角形座標
$base->drawImage($idraw); # 四角形を描画
ob_clean();
header(“Content-Type: image/jpeg”); //表示する画像ヘッダー
echo $base;
$base->clear();