유

이미지에 박스 넣기

//이미지에 네모 박스 집어넣기
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);

[이 게시물은 관리자님에 의해 2011-10-31 17:12:10 PHP & HTML에서 이동 됨]
|

댓글 2개

도움이 많이 되었습니다..감사합니다.
댓글을 작성하시려면 로그인이 필요합니다.

프로그램

8,188건
+
제목 글쓴이 날짜 조회
12-01-11 조회 2,755
12-01-11 조회 1.2만
12-01-10 조회 2,852
12-01-08 조회 3,444
12-01-05 조회 5,335
11-12-29 조회 3,053
11-12-27 조회 2,839
11-12-25 조회 3,021
11-12-22 조회 3,454
11-12-14 조회 2,919
11-12-12 조회 3,540
11-11-28 조회 3,377
10-10-19 조회 2,835
08-09-05 조회 3,756
08-09-05 조회 3,571
08-06-14 조회 3,315
08-04-22 조회 3,592
08-04-17 조회 3,596
07-10-03 조회 4,212
07-10-03 조회 3,608
07-10-03 조회 7,289
07-10-03 조회 4,569
07-10-03 조회 3,265
07-10-03 조회 2,855
07-10-02 조회 3,571
07-10-02 조회 3,100
07-09-27 조회 5,021
07-09-27 조회 3,845
06-09-26 조회 3,515
06-09-26 조회 4,733
06-09-22 조회 3,908
06-09-22 조회 3,523
06-09-22 조회 4,268
06-09-21 조회 4,204
06-08-18 조회 3,693
05-11-30 조회 4,743
05-07-15 조회 4,591
05-03-23 조회 4,655
05-03-14 조회 3,321
05-03-13 조회 2,697
04-08-05 조회 5,769