How can we get the properties (size, type, width, height) of
an image using PHP image functions?

Answer Posted / kartihk

getimagesize ( string filename [, array imageinfo])

Returns an array with 4 elements.
Index 0 contains the width of the image in pixels.
Index 1 contains the height.
Index 2 a flag indicating the type of the image. 1 = GIF, 2
= JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP, 7 = TIFF(intel
byte order), 8 = TIFF(motorola byte order, 9 = JPC, 10 =
JP2, 11 = JPX.
Index 3 is a text string with the correct height="yyy"
width="xxx" string that can be used directly in an IMG tag.

<?php
$imgp = getimagesize ("img/flag.jpg");
echo "<img src=\"img/flag.jpg\" {$imgp[3]}>";
?>

Is This Answer Correct ?    9 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Tell me is it possible to remove the html tags from data?

524


What is the difference between the functions strstr() and stristr()?

534


What is memcache?

536


Why did you choose this particular career path?

8347


which will print out the php call stack?

583






Which is better #define or enum?

522


What is uniqid php?

572


What is the difference between == and === in php?

547


Which function is used in php to check the data type of any variable?

511


How to close a session properly?

522


How can we make a constant in php?

552


How to get a total number of elements used in the array?

500


What is associative array in php?

530


Which is better php praogramming or cad/cam scope wise and also salaray wise?

1570


Explain the difference between php4 and php5.

546