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 is better get or post method?
Which array function checks if the particular key exists in the array?
What is the method to register a variable into a session?
How can php and javascript interact?
What is polymorphism with example in php?
How does php session work?
Is null in php?
What is composer phar?
How can I embed a java program in php file and what changes have to be done in php.ini file?
how can i develop forum code? any one pleale help me on this question
What is php built on?
Is wordpress a php framework?
Can we use session in mvc?
How a constant is defined in a php script?
What is the importance of parser in php?