function textToImage($text, $fname, $fsize) {
$text = iconv("EUC-KR", "UTF-8", $text); // 한글지원
$padding = 10; // 이미지여백
$ttf ="폰트가 있는 서버경로";
$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);
$bcolor = imagecolorallocate ($image, 255, 255, 255);
$fcolor = imagecolorallocate ($image, 255, 0, 0);
imagefilledrectangle($image, 0, 0, $xsize, $ysize, $bcolor);
imagettftext($image, $fsize, 0, $padding, $fsize+$padding, $fcolor, $ttf, $text);
imagejpeg($image,$fname, 85);
imagepng($image);
imagedestroy($image);
}
textToImage("한글 English 특수문자 ♥","title1.jpg","25");