[펌] GD 함수 간단 설명

       
int imagecreatefromjpeg (string filename)


– 화일또는 url로 부터 jpg화일을 생성하는 함수


– $im = @ImageCreateFromJPEG ($imgname);


————————————————————-



int imagecolorallocate (int im, int red, int green, int blue)


– 이미지를 위한 색을 할당하는 함수


– $color = ImageColorAllocate ($im, 255, 255, 255);


————————————————————-



int imagestring (int im, int font, int x, int y, string s, int col)


– 이미지에 원하는 위치(x,y)에 원하는 색(col)으로 문자열(string)을 쓴다


– font 인수는 1에서 5까지, col 인수는 imagecolorallocate() 함수에서 할당한 색의 값을 사용


– ImageString ($im, 1, 5, 5, “hahahaha”, $color);


————————————————————-



int imagejpeg (int im [, string filename [, int quality]])


– 이미지를 화일로 만들거나 웹브라우져에 출력한다


– filename 인수을 사용하면 인수에 주어진 이름으로 화일을 만든다, quality 는 압축율(백분율)을 의미한다


– Imagejpeg($im);


————————————————————-



int imagefilledrectangle (int im, int x1, int y1, int x2, int y2, int col)


– 이미지에 직사각형을 그린다
– x1,y1 인수는 왼쪽상단 시작부분이고 y2,y2 왼쪽하단 마지막부분이다


– ImageFilledRectangle ($im, 0, 0, 150, 30, $color);


————————————————————-



array imagettftext (int im, int size, int angle, int x, int y, int col, string fontfile, string text)


– 이미지에 트루타입 글꼴을 이용해서 문자열을 쓴다


– fontfile 인수는 트루타입 글꼴화일 이름이나 경로를 쓴다, size는 글꼴의 크기, angle는 각을 의미함


– 문자열 길이에 제한이 있다 255자 까지만 사용할수 있다


– ImageTTFText ($im, 20, 0, 10, 20, $color, “/path/arial.ttf”, “Testing… Omega: Ω”);


————————————————————-



int imagedestroy (int im)


– 이미지를 삭제한다


– imagedestroy($im);


————————————————————-



int imagetypes (void)


– 이미지의 타입을 되돌려준다


– 되돌려 주는 값 IMG_GIF, IMG_JPG, IMG_PNG, IMG_WBMP


– $image_type = imagetypes();


————————————————————-


int imageline (int im, int x1, int y1, int x2, int y2, int col)


– 이미지에 선을 그린다


– imageline($im, 0, 0, 150, 30, $color);



————————————————————-



int imagecreate (int x_size, int y_size)


– 새로운 이미지를 생성한다


– x_size인수는 넓이 y_size 인수는 높이


– $im = @ImageCreate (50, 100)



————————————————————-



int imagesy (int im) or int imagesx (int im)


– 이미지의 높이와 넓이를 리턴한다


– $im_height = imagesy($im);


– $im_widht = imagesx($im);



————————————————————-



int imagecopyresized (int dst_im, int src_im, int dstX, int dstY, int srcX, int srcY, int dstW, int dstH, int srcW, int srcH)


– 이미지의 크기를 원하는 크기로 변경 한다음 저장함


– $new_w=100;
$new_h=100;


$dst_img=ImageCreate($new_w,$new_h);
$src_img=ImageCreateFromGif(“./imgtest.gif”);


ImageCopyResized($dst_img,$src_img,0,0,0,0,$new_w,$new_h,ImageSX($src_img),ImageSY($src_img));



————————————————————-


int imagestringup (int im, int font, int x, int y, string s, int col)


– 이미지에 문자를 수직으로 쓴다


– font인수는 1부터 5까지 사용할수 있다


– imagestringup($im, 1, 5, 5, “hahahaha”, $color);



————————————————————-



int imagecreatefromstring (string image)


– 문자열에 있는 이미지 스크림($im)으로 부터 새로운 이미지를 만든다



————————————————————-



int imagecolortransparent (int im [, int col])


– 이미지의 특정색을 투명이미지로 만든다


– $im = imagecreate(100,100);
$color = ImageColorAllocate($im, 255, 0, 0);
$trans = imagecolortransparent($im, $color);


– ImageColorTransparent($im_str, $black);



————————————————————-



int imagecolorstotal (int im)


– 이미지의 팔레트에 있는 색의 갯수를 리턴한다


– $color_total = imagecolorstotal ($im);


————————————————————-


int imagecolorat (int im, int x, int y)


– 이미지에서 특정위치에서 1픽셀의 색값을 얻는다


– $color_index = imagecolorat($im, $start_x, $start_y);


————————————————————-



array imagecolorsforindex (int im, int index)


– 이미지에 imagecolorat()를 실행한 값으로 부터 RGB 값을 배열로 되돌려준다


– $color_tran = imagecolorsforindex($im, $color_index);


$color_tran[“red”] $color_tran[“green”] $color_tran[“blue”]
 



출처 : PHPSCHOOL ( http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=4763&sca=&sfl=wr_subject%7C%7Cwr_content&stx=gd+%C5%F5%B8%ED&sop=and)

You may also like...

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다