top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

How can I know the properties(size,type,width etc) of an image in PHP?

+1 vote
53 views
How can I know the properties(size,type,width etc) of an image in PHP?
posted May 16, 2014 by Mohit Sharma

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

0 votes

The getimagesize() function will determine the size of image file including flash file(swf).
Syntax:--
list($width, $height, $type, $attr) = getimagesize("image_name.jpg");

Code

This is a sample code, change image_name to your image name and test it!

<?php

list($width, $height, $type, $attr) = getimagesize("image_name.jpg");

echo "Image width " .$width;
echo "
";
echo "Image height " .$height;
echo "
";
echo "Image type " .$type;
echo "
";
echo "Attribute " .$attr;

?>

When you run this script you will see the result like this

Image width 379
Image height 344
Image type 2
Image attribute width="379" height="344"

You will get the width, height, type of an image and also attribute of an image, I use this function in my image upload form.

answer May 16, 2014 by Vrije Mani Upadhyay
Similar Questions
0 votes

I have created a form which take in values like
NAME
ADDRESS
EMAIL ID
PHOTO
PHONE NUMBER

i want to add these values into database, but i am having a problem in inserting the Image (photo).

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...