RSS구독하기:SUBSCRIBE TO RSS FEED
즐겨찾기추가:ADD FAVORITE
글쓰기:POST
관리자:ADMINISTRATOR

// 호출시
put_gdimage('원본파일명', 생성가로, 생성세로, '저장될파일명');

// 정상생성여부 확인시 : 정상생성시 1을 리턴, 이외는 실패

// gd 이미지 생성
// $img_name = 생성에 사용될 원본 파일명, $width = 생성이미지 가로크기, $height = 생성이미지 세로크기, $save_name = 저장될 파일명
function put_gdimage($img_name, $width, $height, $save_name){

// GD 버젼체크
$gd = gd_info();
$gdver = substr(preg_replace("/[^0-9]/", "", $gd['GD Version']), 0, 1);
if(!$gdver) return "GD 버젼체크 실패거나 GD 버젼이 1 미만입니다.";

$srcname = "../upload/goods/".$img_name;
$timg = getimagesize($srcname);
if($timg[2] != 1 && $timg[2] != 2 && $timg[2] != 3) return "확장자가 jp(e)g/png/gif 가 아닙니다.";

// jpg, jpeg
if($timg[2] == 2){

$cfile = imagecreatefromjpeg($srcname);
// gd 버전별로
if($gdver == 2){
$dest = imagecreatetruecolor($width, $height);
imagecopyresampled($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}else{
$dest = imagecreate($width, $height);
imagecopyresized($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}
imagejpeg($dest, "../upload/goods/".$save_name, 90);

// png
}else if($timg[2] == 3){

$cfile = imagecreatefrompng($srcname);
if($gdver == 2){
$dest = imagecreatetruecolor($width, $height);
imagecopyresampled($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}else{
$dest = imagecreate($width, $height);
imagecopyresized($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}
imagepng($dest, "../upload/goods/".$save_name, 90);

// gif
}else if($timg[2] == 1){

$cfile = imagecreatefromgif($srcname);
if($gdver == 2){
$dest = imagecreatetruecolor($width, $height);
imagecopyresampled($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}else{
$dest = imagecreate($width, $height);
imagecopyresized($dest, $cfile, 0, 0, 0, 0, $width, $height, $timg[0], $timg[1]);
}
imagegif($dest, "../upload/goods/".$save_name, 90);
}
// 메모리에 있는 그림 삭제
imagedestroy($dest);
return 1;
}

이올린에 북마크하기
2008/01/31 10:45 2008/01/31 10:45
http://jiny.kr/trackback/269
전체 (406)
지니소식 (4)
자료실 (4)
정보|뉴스 (5)
SmartPhone (1)
Languages (206)
Server (153)
Database (27)
Design (4)
Gallery (0)
분류하기귀찬.. (2)
«   2012/02   »
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29      
  1. 창의력과 상상력을 넘어서  2009
    Tomcat 6.0 기본 환경 설정
  2. 닥공  2009
    서블릿 tomcat 6.0 실행시 에러
  1. 2010/07 (1)
  2. 2010/05 (1)
  3. 2010/02 (3)
  4. 2010/01 (3)
  5. 2009/05 (2)
Statistics Graph