if your using it on a website - rather than creating all the thumbnails yourself (really really tiresome if you have alot of pics) here is a wee php function I wrote which can scale a pic down to whatever size thumbnail you wish.
It keeps image proportions so your images dont end up looking stretched etc and handles .gif, .jpg and .png - It does not however check if a thumbnail already exsists before generating a new one. It simply overwrites the one currently there. This can make page generation slow if it is trying to generate new thumbnails everytime. I recommend using something like
Code:
if(!getimagesize("path/to/image.jpg"))
{
//run function
}
However you need to ensure that PHP's error reporting is set not to show warnings as getimagesize also generates a warning as well as returning FALSE;
Ok on with the function :
Code:
//-------------------------------------------------------------------------//
// Function : createthumb
// Create a thumbnail of an image. Returns nothing (handles gif, jpg, png)
//-------------------------------------------------------------------------//
function createthumb($name,$filename,$new_w,$new_h){
$system=explode('.',$name);
if (preg_match('/jpg|jpeg/',$system[1])){
$src_img=imagecreatefromjpeg($name);
}
if (preg_match('/png/',$system[1])){
$src_img=imagecreatefrompng($name);
}
if (preg_match('/gif/',$system[1])){
$src_img=imagecreatefromgif($name);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
$scale = min($new_w/$old_x, $new_h/$old_y);
if ($scale < 1) {
$thumb_w = floor($scale*$old_x);
$thumb_h = floor($scale*$old_y);
}
else
{
$thumb_w = $old_x;
$thumb_h = $old_y;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y);
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
} elseif (preg_match("/jpg/",$system[1])) {
imagejpeg($dst_img,$filename);
} else {
imagegif($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
variables are :
- $name - File to generate thumb from (inc path eg: uploads/images/pic.jpg)
- $filename - What to save thumb as (inc path eg: uploads/images/thumbs/tn_pic.jpg)
- $new_w - maximum width of thumbnail
- $new_h - maximum height of thumbnail
the direcory you are writing the thumbs to needs to have correct permissions oh and dont worry if you supply it an image which is smaller than the maximum height || width it keeps it as is 
ta
v_Ln