title: Imagemagick PDF tp JPG bad quality PHP
body: <p>I have a big pdf file that about >100mb.</p>
  
  <p>I want to save that pdf page by page converting to jpg.</p>
  
  <p>My php script works well but image quality sucks even quailty set to 100. Jpg output max width set to 1024.</p>
  
  <p>Each file size about 2.5mb. I have searched for this problem but i get everytime about command line solutions. I must use php.</p>
  
  <pre><code>$file = 'e-magazine/1/ebook.pdf';
  
  if($file === null &amp;&amp; !file_exists($file)) {
      throw new \Exception('FILE NOT EXISTS');
  }
  
  $nop = new \Imagick($file);
  
  for($i = 0; $i &lt;= $nop-&gt;getnumberimages(); $i++) {
      $image_file = 'e-magazine/1/'.($i+1).'.jpg';
  
      $im = new \Imagick();
  
      $im-&gt;readimage($file.'['.$i.']');
      $im-&gt;setImageCompressionQuality(100);
      $im-&gt;setimageformat('jpeg');
      $im-&gt;resizeImage(1024, 0, \Imagick::FILTER_CATROM, 1);
      $im-&gt;writeimage($image_file);
  
      $tm = new \Imagick();
      $tm-&gt;readimage($image_file);
      $tm-&gt;setImageCompressionQuality(60);
      $tm-&gt;setimageformat('jpeg');
      $tm-&gt;resizeImage(200, 0, \Imagick::FILTER_CATROM, 1);
      $tm-&gt;writeimage('e-magazine/1/thumbnails/'.($i+1).'_thumb.jpg');
  }
  </code></pre>
  
  <p>What can i do to correct file quality?</p>