$height) { $n_width = 120; $n_height = 80; } else { $n_width = 80; $n_height = 120; } } elseif($size == "normal") { if($width>$height) { $n_width = 600; $n_height = 400; } else { $n_width = 400; $n_height = 600; } } else { if($n_width == 0) { $n_width = $width; } if($n_height == 0) { $n_height = $height*($n_width/$width); } } $newimage=imagecreatetruecolor($n_width,$n_height); imagecopyresampled($newimage,$image,0,0,0,0,$n_width,$n_height,$width,$height); $image = $newimage; ImageJPEG($image); // output to browser ImageDestroy($image); ?>