$fuzz = 0.1;
$im = new Imagick();
$im->readimage('файл.jpg');
$im->setImageFormat('png');
$max = $im->getQuantumRange();
$max = $max["quantumRangeLong"];
$im->trimImage($fuzz * $max);
$im->transparentPaintImage($im->getImagePixelColor(0, 0), 0, $fuzz * $max, FALSE);
header('Content-Type: image/png');
echo $im->getImageBlob();