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
Which operator is used to concatenate two strings in PHP?
Where sessions stored in PHP?
Tell us how to create an array of a group of items inside an html form?
Explain NULL?
Can I include php in javascript?
where do we use htaccess?
How to convert a character to an ascii value?
What are new features in php 7?
What is the difference between for and foreach in php?
What is the purpose of the '.frm' file extension? What do thes file contain?
How to generate a character from an ascii value?
Does facebook use php framework?
Which function will suitably replace 'x' if the size of a file needs to be checked? $Size=x(filename);
What is an associative array?
How do you call a constructor for a parent class?