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

What is button in html?

781


How to download file in php?

768


What is php and its advantages?

713


What is the difference between fopen() and fclose()?

844


Which is useful for method overloading?

872


What is the difference between $argv and $argc? Give example?

713


Can we extend two classes in php?

751


What is session in php why it is use?

720


How many ways to include variables in double-quoted strings in php?

800


List types of array are available in php?

769


What are global variables in php?

717


How can php and html interact?

821


Can a trait extend a class php?

747


Does php 7 support mysql?

769


Do you know how to declare an array in php?

741