php, codeigniter
png 이미지 글자 쓰기
디츠
2015. 1. 11. 14:40
* button.php
<?php
header("Content-type: image/png");
$string = $_GET['text'];
$im = imagecreatefrompng("button.png");
$orange = imagecolorallocate($im, 60, 87, 156); // 60,87,156은 RGB값
$px = (imagesx($im) - 7.5 * strlen($string)) / 2; // 7.5는 한글자의 폭
imagestring($im, 4, $px, 9, $string, $orange); // 4는 폰트종류, $px는 x축, 9는 y축
imagepng($im);
imagedestroy($im);
?>
* 이미지 실시간 표시
<html>
<body>
<img src="button.php?text=intro" />
<img src="button.php?text=member" />
<img src="button.php?text=history" />
<img src="button.php?text=mission" />
</body>
</html>
출처 : https://opentutorials.org/course/62/5137