The following code works like a charm:
<?php
$im = new imagick('file.pdf[0]');
$im->setImageFormat( "jpg" );
header( "Content-Type: image/jpeg" );
echo $im;
?>
But what if I need to include that image in an existing html page? If I remove the header image/jpeg it shows the image as text. I'm looking for an ImageMagick method that can do the trick. Any advice?