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
How to get elements in reverse order of an array in php?
What is abstraction php?
What the difference between the 'bitwise and' operator and the 'logical and' operator?
What is difference between compile time and run time polymorphism?
Tell me is it possible to submit a form with a dedicated button?
How can we know the total number of elements of Array?
Write down the code for save an uploaded file using php?
Php program to generate fibonacci series?
How to calculate the length of a string?
How to create and destroy cookies in php?
What is xss and csrf?
What is the use of magic function in php?
Explain the difference between isset() and empty()?
What is the use of addslashes in php?
what is mean by portal