imagestringup DRAW a STRING vertically in an image.
This function considers upper-left at $x = 0, $y = 0.
1 ≤ $font ≤ 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or any of your own font identifiers registered with imageloadfont.
TTF fonts are allowed by this function.
This function returns TRUE on success or FALSE on failure.
<?php
bool imagestringup ( GdImage $image,
GdFont|int $font,
int $x,
int $y,
string $string,
int $color )
where,
$image = The image identifier
$font = The font to be used
$x = The x-coodinate to start in the image
$y = The y-coodinate to start in the image
$string = The STRING to written
$color = The color to be used
?>
$image
The image identifier.
$font
The font to be used.
$x
The x-coodinate to start in the image.
$y
The y-coodinate to start in the image.
$string
The string to be horizontally written.
$color
The color to be used to draw the character created by imagecolorallocate.
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$gdf_font_name = "gdf/04b.gdf";
$font_size = 18;
$angle_txt = 0;
$pos_x = 20;
$pos_y = 380;
$txt = '+ Alea jacta est!';
$gdffile01 = 'png/PNG 016 01.png';
$im01 = imagecreate(60, 400);
$bkg_color = imagecolorallocate($im01, 255, 192, 192);
$txt_color = imagecolorallocate($im01, 80, 0, 0);
$gdf_fnt = imageloadfont($gdf_font_name);
imagestringup($im01, $gdf_fnt, $pos_x, $pos_y,
$txt, $txt_color);
imagepng($im01, $gdffile01);
imagedestroy($im01);
echo $gdffile01; ?><br><br>
<img src="<?php echo $gdffile01; ?>"
alt="<?php echo $gdffile01; ?>"
title="<?php echo $gdffile01; ?>">
RESULT PNG 016 01.png+ Alea jacta est! was written with the font 04b.gdf.
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$ttf_font_name = "ttf/VeraSeBd.ttf";
$font_size = 16;
$angle_txt = 0;
$pos_x = 20;
$pos_y = 160;
$txt = '+ Alea jacta est!';
$ttffile02 = 'png/PNG 017 02.png';
$im02 = imagecreate(60, 200);
$bkg_color = imagecolorallocate($im02, 25, 172, 72);
$txt_color = imagecolorallocate($im02, 80, 0, 0);
$ttf_fnt = $ttf_font_name;
imagestringup($im02, 2, $pos_x, $pos_y, $txt, $txt_color);
imagepng($im02, $ttffile02);
imagedestroy($im02);
?>
<?php echo $ttffile02; ?><br><br>
<img src="<?php echo $ttffile02; ?>"
alt="<?php echo $ttffile02; ?>"
title="<?php echo $ttffile02; ?>">
RESULT PNG 017 02.png+ Alea jacta est!.
When using a ttf font, no matter which one is used, the result will look similar to the one displayed in this exercise.
EXERCISE
<?php
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$ttf_font_name = "ttf/Vera.ttf";
$font_size = 32;
$angle_txt = 0;
$pos_x = 20;
$pos_y = 180;
$txt = '+ Alea jacta est!';
$ttffile03 = 'png/PNG 018 03.png';
$im03 = imagecreatetruecolor(60, 200);
$red = mt_rand(0, 255);
$green = mt_rand(0, 255);
$blue = mt_rand(0, 255);
$bkg_color = imagecolorallocate($im03, $red, $green, $blue);
$txt_color = imagecolorallocate($im03, 0, 255, 255);
$ttf_fnt = $ttf_font_name;
imagestringup($im03, $font_size, $pos_x, $pos_y,
$txt, $txt_color);
imagepng($im03, $ttffile03);
imagedestroy($im03);
echo $ttffile03; ?><br><br>
<img src="<?php echo $ttffile03; ?>"
alt="<?php echo $ttffile03; ?>"
title="<?php echo $ttffile03; ?>">
RESULT PNG 018 03.png+ Alea jacta est!.
When using a ttf font, no matter which one is used, the result will look similar to the one displayed in this exercise.
EXERCISE
<?php
// RUN this code several times
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$ttf_font_name = "ttf/Vera.ttf";
$font_size = 32;
$angle_txt = 0;
$pos_x = 20;
$pos_y = 180;
$txt = '+ Alea jacta est!';
$ttffile04 = 'png/PNG 018 04.png';
$im04 = imagecreate(60, 200);
$red = mt_rand(0, 255);
$green = mt_rand(0, 255);
$blue = mt_rand(0, 255);
$bkg_color = imagecolorallocate($im04, $red, $green, $blue);
$txt_color = imagecolorallocate($im04, 0, 255, 255);
$ttf_fnt = $ttf_font_name;
imagestringup($im04, $font_size, $pos_x, $pos_y,
$txt, $txt_color);
imagepng($im04, $ttffile04);
imagedestroy($im04);
echo $ttffile04; ?><br><br>
<img src="<?php echo $ttffile04; ?>"
alt="<?php echo $ttffile04; ?>"
title="<?php echo $ttffile04; ?>">
RESULT PNG 018 04.png+ Alea jacta est!
This is just one of the possible results for this exercise.
EXERCISE
<?php
// RUN this code several times
echo 'PHP VERSION: ' . PHP_VERSION . '<br><br>';
$ttf_font_name = "ttf/Vera.ttf";
$font_size = 32;
$angle_txt = 0;
$pos_xu = 20;
$pos_yu = 180;
$pos_xh = 26;
$pos_yh = 170;
$txt = '* Alea jacta est!';
$ttffile05 = 'png/PNG 0030 05.png';
$im05 = imagecreate(200, 200);
$red = mt_rand(0, 255);
$green = mt_rand(0, 255);
$blue = mt_rand(0, 255);
$bkg_color = imagecolorallocate($im05, $red, $green, $blue);
$txt_color = imagecolorallocate($im05, 0, 255, 255);
$ttf_fnt = $ttf_font_name;
imagestring($im05, $font_size, $pos_xh, $pos_yh, $txt, $txt_color);
imagestringup($im05, $font_size, $pos_xu, $pos_yu, $txt, $txt_color);
imagepng($im05, $ttffile05);
imagedestroy($im05);
echo $ttffile05; ?><br><br>
<img src="<?php echo $ttffile05; ?>"
alt="<?php echo $ttffile05; ?>"
title="<?php echo $ttffile05; ?>">
RESULT PNG 0030 05.png* Alea jacta est!
This is just one of the possible results for this exercise.