PHP & Others

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"]

관련자료

댓글 0
등록된 댓글이 없습니다.
Today's proverb
“무릇 물이란 지세를 따라 흐르되 작은 틈도 놓치지 않고 적시니 지혜를 갖춘 자와 같고, 움직이면서 아래로 흘러가니 예를 갖춘 자와 같으며, 어떤 깊은 곳도 머뭇거리지 않고 들어가니 용기를 가진 자와 같고 장애물이 막혀서 갇히면 고요히 맑아지니 천명을 아는 자와 같으며, 험한 곳을 거쳐 멀리 흐르지만 끝내 남을 허물어뜨리는 법이 없으니 덕을 가진 자와 같다. 천지는 이것으로 이루어지고, 만물은 이것으로 살아가며, 나라는 이것으로 안녕을 얻고, 만사는 이것으로 평안해지며, 만물은 이것으로 바르게 되는 것이다. 이것이 지혜로운 자가 물을 좋아하는 이유이다.” (한영, <<한시외전>>)