I'm getting image thumbnail but background is black.i could not understand why it is happening.Though i found this script in stackoverflow. Is it problem in gd library.i'm using xampp
makeThumbnails($upload_dir.$new_nm,227,182,$upload_dir_thumb.$new_nm);
function makeThumbnails($src,$w,$h,$dir)
{
$arr_image_details = getimagesize($src);
$original_width = $arr_image_details[0];
$original_height = $arr_image_details[1];
if ($original_width > $original_height) {
$new_width = $w;
$new_height = intval($original_height * $new_width / $original_width);
} else {
$new_height = $h;
$new_width = intval($original_width * $new_height / $original_height);
}
$dest_x = intval(($w - $new_width) / 2);
$dest_y = intval(($h - $new_height) / 2);
if ($arr_image_details[2] == 1) {
$imgt = "ImageGIF";
$imgcreatefrom = "ImageCreateFromGIF";
}
if ($arr_image_details[2] == 2) {
$imgt = "ImageJPEG";
$imgcreatefrom = "ImageCreateFromJPEG";
}
if ($arr_image_details[2] == 3) {
$imgt = "ImagePNG";
$imgcreatefrom = "ImageCreateFromPNG";
}
if ($imgt) {
$old_image = $imgcreatefrom($src);
$new_image = imagecreatetruecolor($w, $h);
imagecopyresized($new_image, $old_image, $dest_x, $dest_y, 0, 0, $new_width, $new_height, $original_width, $original_height);
$imgt($new_image, $dir);
}