imagestring
Description
The imagestring of Image for PHP draw a string horizontally.
Syntax
imagestring( GdImage $image, GdFont|int $font, int $x, int $y, string $string, int $color ): bool
Parameters
image
A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor().
font
Can be 1, 2, 3, 4, 5 for built-in fonts in latin2 encoding (where higher numbers corresponding to larger fonts) or GdFont instance, returned by imageloadfont().
x
x-coordinate of the upper left corner.
y
y-coordinate of the upper left corner.
string
The string to be written.
color
A color identifier created with imagecolorallocate().
Return
Returns true on success or false on failure.
Examples
1 · return
<? $width = 100; $height = 100; $image = imagecreatetruecolor($width, $height); $red = 255; $green = 255; $blue = 255; $color = imagecolorallocate($image, $red, $green, $blue); $font = 1; $x = 0; $y = 0; $string = "string"; $return = imagestring($image, $font, $x, $y, $string, $color); var_export($return);
true
2 · base64
<? $width = 100; $height = 100; $image = imagecreatetruecolor($width, $height); $red = 255; $green = 255; $blue = 255; $color = imagecolorallocate($image, $red, $green, $blue); $font = 1; $x = 0; $y = 0; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); $font = 2; $x = 0; $y = 20; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); $font = 3; $x = 0; $y = 40; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); $font = 4; $x = 0; $y = 60; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); $font = 5; $x = 0; $y = 80; $string = "string"; imagestring($image, $font, $x, $y, $string, $color); ob_start(); imagepng($image); $output = ob_get_clean(); echo '<!doctype html> <html> <body> <img src="data:image/png;base64,' . base64_encode($output) . '"> </body> </html>';
<!doctype html> <html> <body> <img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAIAAAD/gAIDAAAACXBIWXMAAA7EAAAOxAGVKw4bAAACf0lEQVR4nO2cwZaDIAxFg8f//2VngWUoJIitKNB7F3NGDVUCRH0BReAbtm370uCHwBcWi4hsL+TlqeCvZDMYl49O6+68bqprkp3q0cSJ87E65+RVPf+/Z9s2vxn/zYn3O+dmdZNnCb0jVNvX2fJO3tFinHNWQUiZOWABAAAAAAAAAEC3VGpSSFciDbwwh1v/BXh5KctxxcKeoK8H1TjftGzElvAHw0rbJDbqoVMpsouv+wkW3x3y7E5CnM44tJmVVd7H2oU/HWfG5vDjEtcnHyzfDB/v/ZmSY6va/nmozgmBqZB/naxnNWS+AN+2welZAAAAAAA98iOzIxfrwI/U/xTrJb/yI69+puj+ZmTvFO1tucbycq3xBpagW6mrB3LpLrEUu1sllvGJBh3gS+KjytaeSf+s502Dl5bRJ86MND1RO9LlKKoMf8moiTvviJ4SK8B71ORrUs/cj4l+b7XEoP66iSQLO2KMv7V56VkAAAAAANATZ1/iRnzpq8RMWEBO6W3WktIb0b8qv2d3VD3AmsUcrw8QTQI7a58X6Zd8iUBhUzI16mP74SadKjGrppGTL0Gdsh+XPWGBLFfDHrPUz4y1ZriJ8vs3/2pMG4WVgZI9x8OwZrWFJ4nclS4Yq3M9xuFttDd4gj/Bwz2fuzAAAADAeQadhFXg+Al+vjp/zDWLBlTmeyLXJ91ak3Hzr/ZUzke1SqlFwqHeUhiK/JLssfSWw+m51h61iHpS9bwPomvw9ZdYWItRU0SKykxXnpLweZWbU4SD8r/CIuB9d7O/8jbrsMHWDyTgFtVovRjmEg7ueh61wQvVK99erZvA4WXATh43O3wY7qjp6FkAAPAQf6WdV/lYidzNAAAAAElFTkSuQmCC"> </body> </html>
Links
Related
Image
- gd_info
- getimagesize
- getimagesizefromstring
- image_type_to_extension
- image_type_to_mime_type
- imageaffine
- imageaffinematrixconcat
- imageaffinematrixget
- imagealphablending
- imageantialias
- imagearc
- imageavif
- imagebmp
- imagechar
- imagecharup
- imagecolorallocate
- imagecolorallocatealpha
- imagecolorat
- imagecolorclosest
- imagecolorclosestalpha
- imagecolorclosesthwb
- imagecolordeallocate
- imagecolorexact
- imagecolorexactalpha
- imagecolormatch
- imagecolorresolve
- imagecolorresolvealpha
- imagecolorset
- imagecolorsforindex
- imagecolorstotal
- imagecolortransparent
- imageconvolution
- imagecopy
- imagecopymerge
- imagecopymergegray
- imagecopyresampled
- imagecopyresized
- imagecreate
- imagecreatefromavif
- imagecreatefrombmp
- imagecreatefromgif
- imagecreatefromjpeg
- imagecreatefrompng
- imagecreatefromstring
- imagecreatefromtga
- imagecreatefromwbmp
- imagecreatefromwebp
- imagecreatefromxbm
- imagecreatefromxpm
- imagecreatetruecolor
- imagecrop
- imagecropauto
- imagedashedline
- imagedestroy
- imageellipse
- imagefill
- imagefilledarc
- imagefilledellipse
- imagefilledpolygon
- imagefilledrectangle
- imagefilltoborder
- imagefilter
- imageflip
- imagefontheight
- imagefontwidth
- imageftbbox
- imagefttext
- imagegammacorrect
- imagegetclip
- imagegetinterpolation
- imagegif
- imageinterlace
- imageistruecolor
- imagejpeg
- imagelayereffect
- imageline
- imageloadfont
- imageopenpolygon
- imagepalettecopy
- imagepalettetotruecolor
- imagepng
- imagepolygon
- imagerectangle
- imageresolution
- imagerotate
- imagesavealpha
- imagescale
- imagesetbrush
- imagesetclip
- imagesetinterpolation
- imagesetpixel
- imagesetstyle
- imagesetthickness
- imagesettile
- imagestringup
- imagesx
- imagesy
- imagetruecolortopalette
- imagettfbbox
- imagettftext
- imagetypes
- imagewbmp
- imagewebp
- imagexbm
- iptcembed
- iptcparse