title: Fastest way to determine image resolution and file type in PHP or Unix command line?
body: <p>I'm currently using ImageMagick to determine the size of images uploaded to the website. By calling ImageMagick's "identify" on the command line it takes about 0.42 seconds to determine a 1MB JPEG's dimensions along with the fact that it's a JPEG. I find that a bit slow.</p>
  
  <p>Using the Imagick PHP library is even slower as it attemps to load the whole 1MB in memory before doing any treatment to the image (in this case, simply determining its size and type).</p>
  
  <p>Are there any solutions to speed up this process of determining which file type and which dimensions an arbitrary image file has? I can live with it only supporting JPEG and PNG. It's important to me that the file type is determined by looking at the file's headers and not simply the extension.</p>
  
  <p><strong>Edit: The solution can be a command-line tool UNIX called by PHP, much like the way I'm using ImageMagick at the moment</strong></p>