영원한사랑

이미지 크롭

인터넷정보2007. 10. 13. 14:25
/*

제작자이름 : 윤준식
제작자메일 : iamthetop@gmail.com
관련사이트 : http://bitdoll.com

*/

/// function Begin
function GlistThumb($target,$saveIMG,$thumbX,$thumbY){
    global
$targetIMG,$sX,$sY,$srcW,$srcH;

   
$targetIMG=getimagesize($target);

    if(
$targetIMG[0]/$targetIMG[1] >= $thumbX/$thumbY )
       
$ratio = floor($targetIMG[1]/$thumbY);
    else
       
$ratio = floor($targetIMG[0]/$thumbX);

   
$sX = ( $targetIMG[0] - $ratio*$thumbX)/2;
   
$sY = ( $targetIMG[1] - $ratio*$thumbY)/2;
   
$srcW = $ratio*$thumbX;
   
$srcH = $ratio*$thumbY;

                if(
$targetIMG[2]==2 and @imagetypes() & IMG_JPG) $im = @imagecreatefromjpeg($target); 
                elseif(
$targetIMG[2]==3 and @imagetypes() & IMG_PNG) $im = @ImageCreateFromPNG($target); 
                elseif(
$targetIMG[2]==1) $im = @ImageCreateFromGIF($target); 
                elseif(
$targetIMG[2]==6) $im = @ImageCreateFromWBMP($target); 

                if(
$im){ 
                   
$check_gd = get_extension_funcs("gd"); 
                    if(
$check_gd){ 
                       
$thumb = @imagecreatetruecolor($thumbX,$thumbY); 
                        if(!
$thumb) $thumb = @ImageCreate($thumbX,$thumbY); 

                       
$test_check=@imagecopyresampled($thumb,$im,0,0,$sX,$sY,$thumbX,$thumbY,$srcW,$srcH); 
                        if(!
$test_check) @ImageCopyResized($thumb,$im,0,0,$sX,$sY,$thumbX,$thumbY,$srcW,$srcH); 

                        if(@
imagetypes() & IMG_PNG) @ImagePNG($thumb,$saveIMG); 
                        else @
ImageJPEG($thumb,$saveIMG); 
                    } 
                } 
            }
//function End