Hi frnds...
Here i am creating thumbnail image...the code is working fine...
The variables are not working calling funtion....if i give static path, its working fine...
incase of dynamic path it displays some errors,but image created..image with full black(no photo).......plz check the below code...
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);
}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
$thumb_w=$new_w;
$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
$thumb_w=$old_x*($new_w/$old_y);
$thumb_h=$new_h;
}
if ($old_x == $old_y) {
$thumb_w=$new_w;
$thumb_h=$new_h;
}
$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);
} else {
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}
$photo1=mysql_real_escape_string($_FILES['photo1']['name']);
$tphoto1=mysql_real_escape_string($_FILES['photo1']['tmp_name']);
$dir="../../chillzone/citybuzz/$category/$dirid";
if(!file_exists($dir))
mkdir($dir)or die("Filename all ready exits");
$dir1="$dir"."/"."$photo1" ; //working....
if($photo1!=""){move_uploaded_file($_FILES['photo1']['tmp_name'], $dir1);}
createthumb('img5.jpg','thumbs/img5.jpg',100,100);//working....
createthumb('$dir1','$dir/thumbs/$photo1',100,100);//Not working(problem here only)
It displays errors:
Notice: Undefined variable: src_img in C:\wamp\www\vvvv.com\admin\thumb.php on line 12
Warning: imagesx(): supplied argument is not a valid Image resource in C:\wamp\www\vvvv.com\admin\thumb.php on line 12
Notice: Undefined variable: src_img in C:\wamp\www\aaa.com\admin\thumb.php on line 13
Warning: imagesy(): supplied argument is not a valid Image resource in C:\wamp\www\vvvv.com\admin\thumb.php on line 13
Notice: Undefined variable: src_img in C:\wamp\www\aaa.com\admin\thumb.php on line 27
Warning: imagecopyresampled(): supplied argument is not a valid Image resource in C:\wamp\www\vvvv.com\admin\thumb.php on line 27
Notice: Undefined variable: src_img in C:\wamp\www\aaa.com\admin\thumb.php on line 36
Warning: imagedestroy(): supplied argument is not a valid Image resource in C:\wamp\www\vvvv.com\admin\thumb.php on line 36