Image information (PHP)

by spyka (http://www.spyka.net)

Use the code below to display the dimensions, mime type and filesize of an image. This can be helpful when wanting to resize an image.

Code:
<?

$info
=getimagesize("image.jpg");

// display details
echo "Image width: ".$info[0]."<br />";
echo 
"Image height: ".$info[1]."<br />";
echo 
"Image type: ".$info[mime]."<br />";
echo 
"Image size: ".$info[bits]."<br />";

?>

Code demo

Image information online demo

Help and comments

Discuss this and other scripts in our webmaster foruns

Learn more about our forums