Php imagecreatetruecolor creates a high-definition image Function
Imagecreatetruecolor () returns an image identifier representing a black image of the specified size.
Based on the Function Definition in your PHP and GD versions. For PHP 4.0.6, the function 4.1.x always exists.
If the Guangdong module is loaded but it requires GD2, a fatal error will be issued and exit when PHP is installed.
Using PHP 4.2.x is a warning rather than an error. Other versions only define this function
Yes,
Look at the instance
<? Php
Header ('content-type: image/png ');
$ Im = @ imagecreatetruecolor (120, 20)
Or die ('cannot Initialize new GD image stream ');
$ Text_color = imagecolorallocate ($ im, 233, 14, 91 );
Imagestring ($ im, 1, 5, 5, 'a Simple Text string', $ text_color );
Imagepng ($ im );
Imagedestroy ($ im );
?>
I propose cooperation in this regard-combined with some examples and then dynamically generated text. However, with this setting, I can get
To transparent background.
<? Php
// Set the content-type
Header ('content-type: image/png ');
// Create the image
$ Im = imagecreatetruecolor (175, 15 );
Imagesavealpha ($ im, true );
// Create some colors
$ White = imagecolorallocate ($ im, 255,255,255 );
$ Gray = imagecolorallocate ($ im, 128,128,128 );
$ Black = imagecolorallocate ($ im, 0, 0, 0 );
Imagefilledrectangle ($ im, 0, 0,150, 25, $ black );
$ Trans_colour = imagecolorallocatealpha ($ im, 0, 0, 0,127 );
Imagefill ($ im, 0, 0, $ trans_colour );
// The text to draw
$ Text = $ _ GET ['text'];
// Replace path by your own font path
$ Font = 'catriel regular. ttf ';
// Add some shadow to the text
Imagettftext ($ im, 9, 0, 13, 16, $ black, $ font, $ text );
// Add the text
Imagettftext ($ im, 9, 0, 12, 15, $ white, $ font, $ text );
// Using imagepng () results in clearer text compared with imagejpeg ()
Imagepng ($ im );
Imagedestroy ($ im );
?>