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
What is the correct line to use within the php.ini file, to specify that 128mb would be the maximum amount of memory that a script may use?
What is the purpose of basename() function in PHP?
What is ltrim?
Explain about the connective abilities of the PHP?
Explain about PHP filter and why it should be used?
Which function would you use to determine the length of a string in php?
Is age interval or ordinal data?
What language is php based on?
What is the use of pear in php?
How to find a substring from a given string in php?
How is it possible to know the number of rows returned in the result set?
Why do we use javascript in php?
What is a composer in PHP?
Where is session value stored php?
Explain php parameterized functions.