Create thumb problem
Posted: Sat Feb 20, 2010 5:04 am
Hi,
I've a big problem
I tried to create a photo gallery.
My problem is in this function. It get a photo from directory and make a thumb.
The problem is that in localhost it work, but on the remote host don't work.
The function don't create "thumb" directory.
Any solution ?
Gd libraries are enabled.
Permission problem ?
How can i solve it ?
I've a big problem
I tried to create a photo gallery.
My problem is in this function. It get a photo from directory and make a thumb.
Code: Select all
function MakeThumb($file){
$path_parts=pathinfo($file);
$extension=$path_parts['extension'];
$dir=$path_parts['dirname'];
$file_name=$path_parts['filename'];
if (!(file_exists($dir."/thumb")))
{
mkdir($dir."/thumb/", 0777);
chmod($dir."/thumb", 0777);
}
$src_img=false;
$thumb_file=$dir."/thumb/".$file_name."_thumb.".$extension;
if (!file_exists($thumb_file) || !CheckThumb($file,$thumb_file)){
if (preg_match('/jpg|jpeg/i',$extension)){
$src_img=imagecreatefromjpeg($file) or die ("Image not found!");
}
if (preg_match('/png/i',$extension)){
$src_img=imagecreatefrompng($file) or die ("Image not found!");
}
if (preg_match('/gif/i',$extension)){
$src_img=imagecreatefromgif($file) or die ("Image not found!");
}
if ($src_img) {
$width = imagesx($src_img);
$height = imagesy($src_img);
$twidth = 150; # width of the thumb 160 pixel
$theight = $twidth * $height / $width; # calculate height
$thumb = @imagecreatetruecolor ($twidth, $theight) or die ("Can't create Image!");
imagecopyresized($thumb, $src_img, 0, 0, 0, 0, $twidth, $theight, $width, $height);
if (preg_match('/jpg|jpeg/i',$extension)){
Imagejpeg($thumb,$dir."/thumb/".$file_name."_thumb.".$extension);
}
if (preg_match('/png/i',$extension)){
Imagepng($thumb,$dir."/thumb/".$file_name."_thumb.".$extension);
}
if (preg_match('/gif/i',$extension)){
Imagegif($thumb,$dir."/thumb/".$file_name."_thumb.".$extension);
}
}
}
return $thumb_file;
}The function don't create "thumb" directory.
Any solution ?
Gd libraries are enabled.
Permission problem ?
How can i solve it ?