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 button in html?
How to download file in php?
What is php and its advantages?
What is the difference between fopen() and fclose()?
Which is useful for method overloading?
What is the difference between $argv and $argc? Give example?
Can we extend two classes in php?
What is session in php why it is use?
How many ways to include variables in double-quoted strings in php?
List types of array are available in php?
What are global variables in php?
How can php and html interact?
Can a trait extend a class php?
Does php 7 support mysql?
Do you know how to declare an array in php?