imagestring

(PHP 3, PHP 4, PHP 5)

imagestring -- 文字列を水平に描画する

説明

bool imagestring ( int image, int font, int x, int y, string s, int col )

imagestring() は、画像 imagecol 色で左上の座標(x, y) (左上が0, 0)に文字列 s を描画します。font が 1, 2, 3, 4, 5 の場合、組込みフォントが使用されます。

例 1. imagestring() の例

<?php
// 100*30 の画像を生成する
$im = imagecreate(100, 30);

// 白色の背景と青色のテキスト
$bg = imagecolorallocate($im, 255, 255, 255);
$textcolor = imagecolorallocate($im, 0, 0, 255);

// 左上に文字列を描画する
imagestring($im, 5, 0, 0, "Hello world!", $textcolor);

// 画像を出力する
header("Content-type: image/png");
imagepng($im);
?>

imageloadfont(), imagettftext() も参照ください。