downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

アルファチャネルを使用した、画像へのすかしの追加> <
Last updated: Fri, 13 Nov 2009

view this page in

例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" の上にこの文字列を重ねて描いた後、その画像を出力します。 この方法を使うと、ボタンのテキストが変わるたびに新たなボタンを作り直す羽目になることを回避できます。 この方法により、動的に画像ボタンを生成できるのです。



add a note add a note User Contributed Notes
PHP による PNG の生成
There are no user contributed notes for this page.

 
show source | credits | stats | sitemap | contact | advertising | mirror sites