title: Convert PDF to high quality JPG using PHP and ImageMagick
body: <p>I'm tearing my hair out.</p>
  
  <p>I have a 300 DPI PDF that I want to turn into a 300 DPI JPG that's 2550x3300.  I am told ImageMagick can do this, so I get ImageMagick to work, but it only returns a JPG that is sized about 1/5 the original PDF size.</p>
  
  <p>It's not the source image--I've done it with several high quality PDFs and they all have the same problem.</p>
  
  <p>After scouring StackOverflow for ideas, this is what I came up with to use:</p>
  
  <pre><code>$im = new imagick($srcimg);
  $im-&gt;setImageResolution(2550,3300);
  $im-&gt;setImageFormat('jpeg');
  $im-&gt;setImageCompression(imagick::COMPRESSION_JPEG); 
  $im-&gt;setImageCompressionQuality(100);
  $im-&gt;writeImage($targetimg);
  $im-&gt;clear();
  $im-&gt;destroy();
  </code></pre>
  
  <p>But it still doesn't work.</p>
  
  <p>I also have tried using $img->resizeImage() to resize the JPG, but then it comes out at really bad quality, if the right size.</p>
  
  <p>Totally stumped.  Appreciate your help!</p>