In my opinion this function is not working as expected, tested for imagemagick version 6.3.7
As described above, the function returns an image with a fixed height and a variable width. Here's a fix that will return a cropped thumbnail with the defined dimensions, without variations in the dimensions.
<?php
$width = 160;
$height = 90;
$i = new Imagick("your image file");
$geo = $i->getImageGeometry();
if(($geo['width']/$width) < ($geo['height']/$height))
{
$i->cropImage($geo['width'], floor($height*$geo['width']/$width), 0, (($geo['height']-($height*$geo['width']/$width))/2));
}
else
{
$i->cropImage(ceil($width*$geo['height']/$height), $geo['height'], (($geo['width']-($width*$geo['height']/$height))/2), 0);
}
$i->ThumbnailImage($width,$height,true);
$i->setImageFormat("png");
header("Content-Type: image/png");
exit($i);
?>