GD를 사용하여 이미지에 박스 넣기

//이미지에 네모 박스 집어넣기
function draw_box(&$im, $x1, $y1, $x2, $y2, $line_color='', $box_color=''){

  if (!empty($line_color)) {

   $r = hexdec(substr($line_color, 1, 2));
   $g = hexdec(substr($line_color, 3, 2));
   $b = hexdec(substr($line_color, 5, 2));
   $line_color = imagecolorallocate($im, $r, $g, $b);
  }

  if (!empty($box_color)) {

   $r = hexdec(substr($box_color, 1, 2));
   $g = hexdec(substr($box_color, 3, 2));
   $b = hexdec(substr($box_color, 5, 2));
   $box_color = imagecolorallocate($im, $r, $g, $b);
  }

  if (!empty($box_color)) imagefilledrectangle($im, $x1, $y1, $x2, $y2, $box_color);

  if (!empty($line_color)) {

   imageline ($im , $x1, $y1 , $x2 , $y1 , $line_color );//윗줄
   imageline ($im , $x1 , $y2 , $x2 , $y2 , $line_color );//아랫줄
   imageline ($im , $x1 , $y1 , $x1 , $y2 , $line_color );//앞줄
   imageline ($im , $x2 , $y1 , $x2 , $y2 , $line_color );//뒷줄
  }
}

사용법
이미지 생성한후, 생성하는 방법은 여러가지가 있습니다.
$src = @imagecreatefromjpeg($src_path);

이미지에 30*30짜리 박스를 그리고
draw_box(&$src, 0, 0, 30, 30, '#000000', '#FFFFFF');

이미지 생성
imagejpeg($src, $copy_path, 90);

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

Posted by 바람부는데로

, , ,
Response
No Trackback , No Comment
RSS :
http://apmusers.com/tt/dbckdghk/rss/response/65

Trackback URL : 이 글에는 트랙백을 보낼 수 없습니다

« Previous : 1 : ... 49 : 50 : 51 : 52 : 53 : 54 : 55 : 56 : 57 : ... 95 : Next »

블로그 이미지

유창화의 블로그(사진은 10년전 모습)

- 바람부는데로

Archives

Calendar

«   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      

이올린 추천글

Site Stats

Total hits:
235019
Today:
60
Yesterday:
87