title: PHP exec ImageMagick always returns 0
body: <p>I'm trying to get ImageMagick to count the amount of pages in a PDF file for me. The function is as follows:</p>
  
  <pre><code>&lt;?php
  function countPdfPages($filepath)
  {
      $magick = "identify -format %n ".$filepath;
      exec($magick, $debug, $result);
      return $result;
  }
  ?&gt;
  </code></pre>
  
  <p>However, that function always returns <code>0</code>. I have verified that ImageMagick is running properly, so that shouldn't be a problem. Am I not using <code>exec()</code> properly? Should I retrieve the output in another way? I've also tried using <code>$debug</code>, but that didn't give me any output, oddly.</p>
  
  <p>I bet I'm doing something stupid here, but I just don't see it. Can anyone give me a push in the right direction? Thanks!</p>