Get Image Information using PHP

  • Avinash
  • 1
  • Feb 19, 2012
  • Web Development

Today I am going to share one quick tip for PHP. In this quick tip article I am going to explain a small function which gives you information about the image.

All you need to pass is just full image document path. You can get three information of any image which are height, width and mime type.

Let’s have a look at code block for the same.

This function will return array containing image height, width and mime type.

function get_image_info($file_path="") { if($file_path!="") { $image_info = getimagesize($file_path); return $image_info; } else { return false; } }
  function get_image_info($file_path="")
  {
    if($file_path!="")
    {
      $image_info = getimagesize($file_path);
      return $image_info;
    }
    else
    {
      return false;
    }
  }

Hope this small function will be useful when you need this.

Related Posts

Written by Avinash

Avinash Zala is leading various projects which deals with the various technology involved with the web. A combination of perfect technical and management skills. Avinash would like to chat with you and convert your imagination into the working system. You can get in touch with him on Facebook and Twitter.

View all posts by: