title: convert pdf to images using php
body: <p>i am trying to get images of a pdf file. but the problem is that my code produce error for some pdf files. probably file size problem </p>
  
  <p>this is my code </p>
  
  <pre><code>$saved_file_location = "images.pdf";
  $destination_dir = "t";
  $Name = "123";
  
  exec('convert -verbose -density 150 '.$saved_file_location.' -crop 1020x490+128+40 -quality 90 '.$destination_dir."/".$Name.'-%03d.jpg');
  sleep(5);
  //echo filesize($destination_dir."/".$Name.'-000.jpg'). "&lt;br&gt;";
  if(filesize($destination_dir."/".$Name.'-000.jpg') &lt; 10000)
  {
      exec('convert -verbose -density 150 '.$saved_file_location.' -crop 1020x490+128+580 -quality 90 '.$destination_dir."/".$Name.'-%03d.jpg');
      sleep(5);
      //echo filesize($destination_dir."/".$Name.'-001.jpg')."&lt;br&gt;";
      if(filesize($destination_dir."/".$Name.'-001.jpg') &lt; 10000)
      {
          exec('convert -verbose -density 150 '.$saved_file_location.' -crop 1020x490+128+1125 -quality 90 '.$destination_dir."/".$Name.'-%03d.jpg');
      }
  }
  </code></pre>
  
  <p>and this error i get</p>
  
  <pre><code>PHP Warning:  filesize(): stat failed for t/123-000.jpg in /home3/domain/pdf_to_images.php on line 10
  </code></pre>
  
  <p>some time the code work fine and produce multiple images of pdf file but some time i get this error</p>