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


Please Help Members By Posting Answers For Below Questions

How to get elements in reverse order of an array in php?

761


What is abstraction php?

724


What the difference between the 'bitwise and' operator and the 'logical and' operator?

707


What is difference between compile time and run time polymorphism?

743


Tell me is it possible to submit a form with a dedicated button?

730


How can we know the total number of elements of Array?

800


Write down the code for save an uploaded file using php?

639


Php program to generate fibonacci series?

728


How to calculate the length of a string?

781


How to create and destroy cookies in php?

675


What is xss and csrf?

694


What is the use of magic function in php?

699


Explain the difference between isset() and empty()?

712


What is the use of addslashes in php?

705


what is mean by portal

1694