PHP에서 GD 라이브러리를 활용해서 썸네일을 만들어주는 함수의 소스 코드입니다. 홈페이지를 만들다 보면 사진첩과 같이 이미지를 다수 노출해야 되는 페이지를 구성할 때 필요한 것이 썸네일이며 이를 이용하면 페이지의 로딩 속도를 향상시켜 주며 원본 이미지를 작게 보여줄 때 좀더 선명하게 표현해줄 수 있습니다. 자신의 필요에 맞게 함수를 구성할 수 있는 분이 아니라면 복사해서 활용해보시면 되겠습니다. 함수 파라메터 끝에는 썸네일을 저장할 파일 경로를 입력하시면 되고 경로를 입력하지 않으면 바로 출력됩니다.

make_thumbnail("원본이미지파일경로", 83, 100, "저장할썸네일파일경로");

웹프로그래머의 홈페이지 정보 블로그 http://hompy.info
<?
make_thumbnail("http://hompy.info/attach/1/1196323499.jpg", 83, 100, "");

function make_thumbnail($source_path, $width, $height, $thumbnail_path){
    list($img_width,$img_height, $type) = getimagesize($source_path);
    if ($type!=1 && $type!=2 && $type!=3 && $type!=15) return;
    if ($type==1) $img_sour = imagecreatefromgif($source_path);
    else if ($type==2 ) $img_sour = imagecreatefromjpeg($source_path);
    else if ($type==3 ) $img_sour = imagecreatefrompng($source_path);
    else if ($type==15) $img_sour = imagecreatefromwbmp($source_path);
    if ($img_width > $img_height) {
        $w = round($height*$img_width/$img_height);
        $h = $height;
        $x_last = round(($w-$width)/2);
        $y_last = 0;
    } else {
        $w = $width;
        $h = round($width*$img_height/$img_width);
        $x_last = 0;
        $y_last = round(($h-$height)/2);
    }
    if ($img_width < $width && $img_height < $height) {
        $img_last = imagecreatetruecolor($width, $height);
        $x_last = round(($width - $img_width)/2);
        $y_last = round(($height - $img_height)/2);

        imagecopy($img_last,$img_sour,$x_last,$y_last,0,0,$w,$h);
        imagedestroy($img_sour);
        $white = imagecolorallocate($img_last,255,255,255);
        imagefill($img_last, 0, 0, $white);
    } else {
        $img_dest = imagecreatetruecolor($w,$h);
        imagecopyresampled($img_dest, $img_sour,0,0,0,0,$w,$h,$img_width,$img_height);
        $img_last = imagecreatetruecolor($width,$height);
        imagecopy($img_last,$img_dest,0,0,$x_last,$y_last,$w,$h);
        imagedestroy($img_dest);
    }
    if ($thumbnail_path) {
        if ($type==1) imagegif($img_last, $thumbnail_path, 100);
        else if ($type==2 ) imagejpeg($img_last, $thumbnail_path, 100);
        else if ($type==3 ) imagepng($img_last, $thumbnail_path, 100);
        else if ($type==15) imagebmp($img_last, $thumbnail_path, 100);
    } else {
        if ($type==1) imagegif($img_last);
        else if ($type==2 ) imagejpeg($img_last);
        else if ($type==3 ) imagepng($img_last);
        else if ($type==15) imagebmp($img_last);
    }
    imagedestroy($img_last);
}
?>
이올린에 북마크하기(0) 이올린에 추천하기(0)
어떤 카페, 어떤 블로그, 어떤 홈페이에도 자유롭게 복사되어 붙여넣기 될 수 있는 플래시의 장점을 살려 홈페이지를 넘나들며 자유로운 메시지 교환을 손쉽게 해볼 수 있는 플래시톡(Flash Talk)입니다. 플래시톡은 채팅과 게시판의 중간단계이며 간편하게 메시지를 작성해서 올릴 수 있습니다. 간편한 메시지 입력, 간편한 메시지 보기에 주안점을 둔 유저인터페이스(UI) 입니다. 차차 로그인 기능이나 나만의 플래시톡을 만들 수 있는 기능 등이 추가될 수 있습니다.

웹프로그래머의 홈페이지 정보 블로그 http://hompy.info



개인용 플래시톡을 만들려면 아래 태그에 빨간색 부분을 자신의 아이디(myid)로 수정해서 사용해야 되며 아이디 개설은 http://www.hompydesign.com/blog/에서 해야합니다. 아이디를 개설하면 블로그 채팅이나 블로그 카운터 등을 사용할 수 있습니다.

[플래시톡 HTML 태그 소스 코드]
<EMBED FlashVars="myid=hompy" pluginspage=http://www.macromedia.com/go/getflashplayer src=http://www.hompydesign.com/flash/flashtalk.swf width=300 height=400 type=application/x-shockwave-flash quality="high"></EMBED>
이올린에 북마크하기(0) 이올린에 추천하기(0)
플래시 액션 스크립트 3.0, 3D 라이브러리로 만들어진 고성능 모션 그래픽스 데모입니다. 최근 PaperVision3D 라는 플래시용 3D 라이브러리에 관심을 가지고 활용해볼 기회만 보고 있었는데 같이 일하는 디자이너가 알려준 링크에서 아래와 같은 플래시를 보니 욕심이 더 생기더군요. 시간을 쪼개서 3D 플래시에 대해 탐구하고 활용방안에 대해 생각해봐야겠습니다.
http://temp.roxik.com/datas/perform/index.html
http://code.google.com/p/papervision3d/

웹프로그래머의 홈페이지정보 블로그 http://hompy.info

이올린에 북마크하기(0) 이올린에 추천하기(0)