imagestringup 


gd apg

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.



  1 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(60400);
$bkg_color imagecolorallocate($im01255192192);
$txt_color imagecolorallocate($im018000);

$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

PNG 016 01.png apr

+ Alea jacta est! was written with the font 04b.gdf.

  2 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(60200);
$bkg_color imagecolorallocate($im022517272);
$txt_color imagecolorallocate($im028000);

   
$ttf_fnt $ttf_font_name;
   
imagestringup($im022$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

PNG 017 02.png apr

+ 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.


  3 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(60200);
$red mt_rand(0255);
$green mt_rand(0255);
$blue mt_rand(0255);
$bkg_color imagecolorallocate($im03$red$green$blue);
$txt_color imagecolorallocate($im030255255);

   
$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

PNG 018 03.png apr

+ 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.


  4 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(60200);
$red mt_rand(0255);
$green mt_rand(0255);
$blue mt_rand(0255);
$bkg_color imagecolorallocate($im04$red$green$blue);
$txt_color imagecolorallocate($im040255255);

   
$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

PNG 018 04.png apr

+ Alea jacta est!

This is just one of the possible results for this exercise.

  5 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(200200);
$red mt_rand(0255);
$green mt_rand(0255);
$blue mt_rand(0255);
$bkg_color imagecolorallocate($im05$red$green$blue);
$txt_color imagecolorallocate($im050255255);

   
$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

PNG 0030 05.png apr

* Alea jacta est!

This is just one of the possible results for this exercise.