To confirm santa's suggestion, getimagesize() does exactly what you're looking for and will likely be as fast as you can get for doing this task.
The underlying C code for the function (for the common image types) literally reads the first few bytes of the file for the required width/height information; you can't get much more streamlined than that.
|