Web Development

Get Image Information using PHP

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.

[cc lang=”php”]
function get_image_info($file_path=””)
{
if($file_path!=””)
{
$image_info = getimagesize($file_path);
return $image_info;
}
else
{
return false;
}
}
[/cc]

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

Shares:

Leave a Reply

Your email address will not be published. Required fields are marked *