Home | Scripts | Tutorials | Books | Hosting | Forums | Links|

Navigation:

Home
Source code
Tutorials
RSS feeds
Articles
Wordpress plugins
Blog
Books
Software
Downloads
Hosting
manuals
Script directory
Training
Our Links






 
 

SPONSORS



 
 

What type of image is it

Once again we are using the GetImageSize function but this time we are going to display what kind of image it is . As we mentioned before the GetImageSize function returns an array with 4 elements . Index 2 is a flag which indicates the type of the image . Here are the flags available

1 = GIF, 2 = JPG, 3 = PNG, 4 = SWF, 5 = PSD, 6 = BMP

Code :

<?php
if($img = @GetImageSize("ihcomputing1.gif"))
{
switch ($img[2])
{
case 1 :
echo "image is a gif";
break;
case 2 :
echo "image is a jpeg";
break;
case 3 :
echo "image type is PNG";
break;
case 4 :
echo "image type is SWF";
break;
case 5 :
echo "image type is PSD";
break;
case 6 :
echo "image type is BMP";
break;
}
}
else
{
echo "image does not exist";
}
?>

Example :

 

image is a gif