CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 The best Function to make a thumbnail + thumbnail prefix..

Print topic Send  topic

Author Message
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
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.