GD
PHP Manual

例1 PHPによるPNGの生成

<?php

header
("Content-type: image/png");
$string $_GET['text'];
$im     imagecreatefrompng("images/button1.png");
$orange imagecolorallocate($im22021060);
$px     = (imagesx($im) - 7.5 strlen($string)) / 2;
imagestring($im3$px9$string$orange);
imagepng($im);
imagedestroy($im);

?>
この例のスクリプトは、<img src="button.php?text"> のようなタグによりあるページからコールされるものです。 上のbutton.phpスクリプトは、この "text" 文字列を引数と し、この場合は "images/button1.png" である基本イメージ の最上部にこの文字列を描いた後、描画後ののイメージを出力します。 この方法は、ボタンのテキストを変更する度に新規のボタンを生成する 必要があるのを回避するために便利な手法です。 この方法により、動的にイメージボタンを生成できます。


GD
PHP Manual