How to check and see an images extension using PHP?
<p>How can I check to see if the image is a PNG, GIF, TIFF and JPG and if so create the thumbnail and save it to the thumb file.</p>

<p>So far I can check and save for JPEG images.</p>

<p>Here is the code below.</p>

<pre><code>&lt;?php

//Name you want to save your file as
$save = 'members/3/images/thumbs/thumb-pic.jpg';

$file = 'members/3/images/pic.jpg';
echo "Creating file: $save"; 


list($width, $height) = getimagesize($file) ;

if ($width &gt;= 180){
 $modwidth = 180;
 $modheight = ((180.0/$width) * $height);
} else {
 $modwidth = $width;
 $modheight = $height;
}

$tn = imagecreatetruecolor($modwidth, $modheight) ;
$image = imagecreatefromjpeg($file) ;
imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ;

// Here we are saving the .jpg, you can make this gif or png if you want
//the file name is set above, and the quality is set to 100%
imagejpeg($tn, $save, 100) ; 
?&gt;
</code></pre>
