Dutch PHP Conference 2025 - Call For Papers

imagestringup

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

imagestringupDraw a string vertically

Опис

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

Draws a string vertically at the given coordinates.

Параметри

image

Об'єкт GdImage, що повертається однією з функцій створення зображення, такою як imagecreatetruecolor().

font

Може бути 1, 2, 3, 4, 5 для вбудованих шрифтів в кодуванні latin2 (де більші числа відповідають більшим шрифтам) або примірником класу GdFont, що повертається функцією imageloadfont().

x

x-coordinate of the bottom left corner.

y

y-coordinate of the bottom left corner.

string

The string to be written.

color

Ідентифікатор кольору, створений за допомогою imagecolorallocate().

Значення, що повертаються

Повертає true у разі успіху або false в разі помилки.

Журнал змін

Версія Опис
8.1.0 Параметром font тепер може бути як і примірник GdFont, так і int. Раніше допускався тільки int.
8.0.0 Тепер image має бути примірником GdImage. Раніше очікувався gd-resource.

Приклади

Приклад #1 imagestringup() example

<?php
// create a 100*100 image
$im = imagecreatetruecolor(100, 100);

// Write the text
$textcolor = imagecolorallocate($im, 0xFF, 0xFF, 0xFF);
imagestringup($im, 3, 40, 80, 'gd library', $textcolor);

// Save the image
imagepng($im, './stringup.png');
imagedestroy($im);
?>

Поданий вище приклад виведе щось схоже на:

Output of example : 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