//Simply pass the parameter in below function n u'll get the resized image.
for Ex.
$sourcefile = SITE_PATH."pro_images/".$main_img_name;
$thumb = "thumb_".$main_img_name;
$endfile = SITE_PATH."pro_images/thumb/".$thumb;
$thumbheight = 80;
$thumbwidth = 80;
$quality = 75;
function createThumbs($sourcefile, $endfile, $thumbwidth, $thumbheight, $quality){
preg_match("'^(.*).(gif|jpe?g|png)$'i", $sourcefile, $ext);
switch (strtolower($ext[2])) {
case 'jpg' :
case 'jpeg': $img = imagecreatefromjpeg ($sourcefile);
break;
case 'gif' : $img = imagecreatefromgif ($sourcefile);
break;
case 'png' : $img = imagecreatefrompng ($sourcefile);
break;
}
//$img = imagecreatefromjpeg($sourcefile);
$width = imagesx( $img ); $height = imagesy( $img );
$scale = $thumbwidth/$width;
$newwidth = ceil($width * $scale);
$newheight = ceil($height * $scale);
// Create a new temporary image.
$tmpimg = imagecreatetruecolor( $newwidth, $newheight );
// Copy and resize old image into new image.
imagecopyresampled( $tmpimg, $img, 0, 0, 0, 0, $newwidth, $newheight, $width, $height );
// Save thumbnail into a file.
imagejpeg( $tmpimg, $endfile, $quality);
}