PHP 8.3.4 Released!

imagestringup

(PHP 4, PHP 5, PHP 7, PHP 8)

imagestringup文字列を垂直に描画する

説明

imagestringup(
    GdImage $image,
    GdFont|int $font,
    int $x,
    int $y,
    string $string,
    int $color
): bool

文字列 string を、指定した座標で垂直に描画します。

パラメータ

image

imagecreatetruecolor()のような画像作成関数が返す GdImage オブジェクト。

font

latin2 エンコーディングの組み込みのフォントの場合は 1, 2, 3, 4, 5 のいずれか (数字が大きなほうが、より大きいフォントに対応します)、あるいは imageloadfont() が返した、GdFont クラスのインスタンスのいずれか。

x

左下隅の x 座標。

y

左下隅の y 座標。

string

書き出す文字列。

color

imagecolorallocate() で作成された色識別子。

戻り値

成功した場合に true を、失敗した場合に false を返します。

変更履歴

バージョン 説明
8.1.0 引数 font は、GdFont クラスのインスタンスと数値を両方受け入れるようになりました。これより前のバージョンでは、数値のみを受け入れていました。
8.0.0 image は、 GdImage クラスのインスタンスを期待するようになりました。 これより前のバージョンでは、有効な gd resource が期待されていました。

例1 imagestringup() の例

<?php
// 100*100 の画像を作成します
$im = imagecreatetruecolor(100, 100);

// テキストを書き込みます
$textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
imagestringup($im, 3, 40, 80, 'gd library', $textcolor);

// 画像を保存します
imagepng($im, './stringup.png');
imagedestroy($im);
?>

上の例の出力は、 たとえば以下のようになります。

出力例 : imagestringup()

参考

add a note

User Contributed Notes 1 note

up
1
Anonymous
21 years ago
function imagestringdown(&$image, $font, $x, $y, $s, $col)
{
$width = imagesx($image);
$height = imagesy($image);

$text_image = imagecreate($width, $height);

$white = imagecolorallocate ($text_image, 255, 255, 255);
$black = imagecolorallocate ($text_image, 0, 0, 0);

$transparent_colour = $white;
if ($col == $white)
$transparent_color = $black;

imagefill($text_image, $width, $height, $transparent_colour);
imagecolortransparent($text_image, $transparent_colour);

imagestringup($text_image, $font, ($width - $x), ($height - $y), $s, $col);
imagerotate($text_image, 180.0, $transparent_colour);

imagecopy($image, $text_image, 0, 0, 0, 0, $width, $height);
}
To Top