I just made this function.. most of the code are from the internet...
How can i rename thumbnail picture ... letsay my orginal picture was "builder.jpg" then thumb_nail picture will be different name "builder_thumb.jpg"
Currenty this function create thumbnail picture name same as orginal picture name..[ie. orginal pic: builder.jpg and thumbnail "builder.jpg"]
function imagetothumb($img,$imgdir,$thumbdir,$thumb_w)
{
if (!file_exists($imgdir.$img))
{
die ("Error: File not found...");
}
// Check if the file extesion is .jpg
$ext = explode('.', $img);
$ext = $ext[count($ext)-1];
if (strtolower($ext) != "jpg")
{
die ("Error: File must be JPEG");
}
// Read the source image
$src_img = ImageCreateFromJPEG($imgdir.$img);
// Get image width and height
$org_h = imagesy($src_img);
$org_w = imagesx($src_img);
// Calculate thumbnail height
$thumb_h = floor($thumb_w * $org_h / $org_w);
// Initialize destination image
$dst_img = ImageCreateTrueColor($thumb_w,$thumb_h);
// Do it!
ImageCopyResized($dst_img, $src_img, 0, 0, 0, 0, $thumb_w, $thumb_h, $org_w, $org_h);
//Save it!
ImageJPEG($dst_img, $thumbdir.$img);
$thumb_img="$thumbdir$img";
return $thumb_img;
}