Control Points for DISTORTION_PERSPECTIVE are pairs of x0, y0, x1, y1 coordinates, where x0/y0 is the original point and x1/y1 is the destination point,
e.g. for a four point distortion:
<?php
$im = new imagick( $fn);
$w=$im->getImageWidth();
$h=$im->getImageHeight();
$im->setImageFormat('png');
$controlPoints = array(
$tLx, $tLy, 0, 0, $tRx, $tRy, $w, 0, $bRx, $bRy, $w, $h, $bLx, $bLy, 0, $h );
$im->distortImage(Imagick::DISTORTION_PERSPECTIVE, $controlPoints, false);
$output = $im->getimageblob();
$outputtype = $im->getFormat();
header("Content-type: $outputtype");
echo $output;
?>