beshoo
Posts: 68
|
Posted: 07/08/2004, 7:23 PM |
|
You can now make your thumbnail with CC2.7 and CCS by this function .
you have to pass some vars
################################################
//$entry is the variable w/ filename
//$path has the path to folder with thumbnails
//$src is the directory with originals
//$prefix is the thumbnail prefix
//$scale is the ammount to scale the original
//$qual is the Quality of the image
the function :
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
//Requires the GD Library
function thumbbeshoo($entry,$src,$path,$prefix,$scale,$qual){
//JPG
if(eregi(".+\.jpe?g$",$entry)){
if(!file_exists("$path/$prefix".$entry)){
$src=ImageCreateFromJPEG("$src/$entry");
$org_h=imagesy($src);
$org_w=imagesx($src);
$scale=($scale/100);
$nwidth=round($org_w*$scale);
$nheight=round($org_h*$scale);
$img=imagecreate($nwidth,$nheight);
ImageCopyResized($img,$src,0,0,0,0,$nwidth,$nheight,$org_w,$org_h);
$new_src=($path.$prefix.$entry);
ImageJPEG($img,$new_src,$qual);
ImageDestroy($img);
ImageDestroy($src);
}//End check for exising thumbnail
}//End jpg check
//GIF
elseif(eregi(".+\.gif$",$entry)){
if(!file_exists("$path/$prefix".$entry)){
$src=ImageCreateFromGIF("$src/$entry");
$org_h=imagesy($src);
$org_w=imagesx($src);
$scale=($scale/100);
$nwidth=round($org_w*$scale);
$nheight=round($org_h*$scale);
$img=imagecreate($nwidth,$nheight);
ImageCopyResized($img,$src,0,0,0,0,$nwidth,$nheight,$org_w,$org_h);
$new_src=($path.$prefix.$entry);
ImageGIF($img,$new_src,75);
ImageDestroy($img);
ImageDestroy($src);
}//End check for exising thumbnail
}//end GIF check
//PNG
elseif(eregi(".+\.png$",$entry)){
if(!file_exists("$path/$prefix".$entry)){
$src=ImageCreateFromPNG("$src/$entry");
$org_h=imagesy($src);
$org_w=imagesx($src);
$scale=($scale/100);
$nwidth=round($org_w*$scale);
$nheight=round($org_h*$scale);
$img=imagecreate($nwidth,$nheight);
ImageCopyResized($img,$src,0,0,0,0,$nwidth,$nheight,$org_w,$org_h);
$new_src=($path.$prefix.$entry);
ImagePNG($img,$new_src,75);
ImageDestroy($img);
ImageDestroy($src);
}//End check for exising thumbnail
}
}
thumbbeshoo('thekra.jpg','E:/c-drive/phpdev/www/ccsu/target','','','20','10');
?>
///////////////////
thank you and best regards
_________________
beshoo Love PHP and CC 4.2 |
|
|
|