웹프로그래밍

Global It Leader!!


PHP


 
 

문자를 이미지로 나타내기 - 신문기사 제목

페이지 정보

작성자 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 댓글 0건 조회 6,653회 작성일 11-04-18 17:43

본문

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<title>imagettfbbox 한글 안깨지게</title>
</head>
<body>
<?
    $text = "text를 이미지로 변환하기"; 
    $text = iconv("EUC-KR", "UTF-8", $text); //

    $padding = 10; #10px

    $fsize = 12; #font size 12 pixels

    $ttf  ="./NanumGothic.ttf"; #path to windows ttf font file

    $size = imagettfbbox($fsize, 0, $ttf, $text);

    $xsize = abs($size[0]) + abs($size[2])+($padding*2);
    $ysize = abs($size[5]) + abs($size[1])+($padding*2);

    $image = imagecreate($xsize, $ysize);


    $white = imagecolorallocate ($image, 255, 255, 255);
    $black = imagecolorallocate ($image, 0, 0, 0);
    imagefilledrectangle ($image, 0, 0, $xsize, $ysize, $white);

    imagettftext($image, $fsize, 0, $padding, $fsize+$padding, $black, $ttf, $text);
                       
           
    #save to file
    imagejpeg($image,"./screenshot.jpg",85); #85%quality
    echo "<img src=\"./screenshot.jpg\">";
?>
</body>
</html>

첨부파일

  • tahoma.ttf (102.8K) 71회 다운로드 | DATE : 2011-04-18 17:43:19

댓글목록

등록된 댓글이 없습니다.

전체 92
게시물 검색
PHP 목록
번호 제목 글쓴이 조회 날짜
92 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 10738 05-10
91 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9454 09-20
90 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9293 06-04
89 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9102 10-14
88 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 9041 10-20
87 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8352 09-18
86 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 8228 05-07
85 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7462 03-31
84 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7238 05-19
83 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 7081 11-10
82 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6848 02-25
81 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6788 05-10
80 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6721 11-10
열람중 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6654 04-18
78 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6595 04-20
77 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 6500 04-22
76 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5753 03-21
75 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5675 11-11
74 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5581 06-08
73 no_profile 오원장 쪽지보내기 메일보내기 자기소개 아이디로 검색 전체게시물 5307 03-19