The imagecharup() function is used to draw a character vertically.
Syntax
imagecharup( img, font, x, y, c, color )
Parameters
img: Create an image with imagecreatetruecolor()
font: Sets the font size. It can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding
x: x-coordinate
y: y-coordinate
c: character to be drawn
color: color identifier
Return
The imagecharup() function returns TRUE on success or FALSE on failure.
Example
The following is an example:
<?php $img = imagecreate(300, 300); $str = 'Demo'; $bg = imagecolorallocate($img, 190, 255, 255); $color = imagecolorallocate($img, 120, 60, 100); imagecharup($img, 5, 30, 50, $str, $color); header('Content-type: image/png'); imagepng($img); ?>
Output
The following is the output:
Example
Let us see another example:
<?php $img = imagecreate(270, 270); $str = 'Example'; $bg = imagecolorallocate($img, 160, 185, 175); $color = imagecolorallocate($img, 100, 120, 100); imagecharup($img, 10, 80, 100, $str, $color); header('Content-type: image/png'); imagepng($img); ?>
Output
The following is the output that draws character E with different dimensions: