-
Problems
This line enable URL Rewriting . It must be enabled via the RewriteEngine directive! and if your .htaccess file is going to use rewrite rules, you should always include this line. Otherwise, you can’t be sure if its enabled or not. The string “on” is case insensitive.
Now we will add some text to our before black square image.For this
<?php
$im = ImageCreate(200,200);
$white = ImageColorAllocate($im,0xFF,0xFF,0xFF);
$black = ImageColorAllocate($im,0x00,0x00,0x00);
ImageFilledRectangle($im,50,50,150,150,$black);
ImageString($im,5,50,160,"A Black Box",$black);
Header('Content-Type: image/png');
ImagePNG($im);
?>
We just add ImageString() which adds text to image.Specify the top-left point of the
text, as well as the color and the font to use. The syntax for Imagestring() is.
ImageString(image, font, x, y, text, color);
Fonts
Fonts in GD are identified by numbers.You can create your own fonts and load them into GD using the ImageLoadFont( )
function. However, these fonts are binary and architecture-dependent. Using True-
Type fonts with the TrueType functions in GD provides much more flexibility.
To add text in a TrueType font to an image, use ImageTTFText( ):
ImageTTFText(image, size, angle, x, y, color, font, text);
The size is measured in pixels. angle is in degrees from 3 o’clock (0 gives horizontal
text, 90 gives vertical text going up the image, etc.). The x and y coordinates specify
the lower-left corner of the text (unlike in ImageString( ), where the coordinates
specify the upper-right corner). The text may include UTF-8* sequences of the form
ê to print high-bit ASCII characters.
USING TRUE TYPE FONT :
<?php
$im = ImageCreate(350, 70);
$white = ImageColorAllocate($im, 0xFF,0xFF,0xFF);
$black = ImageColorAllocate($im, 0x00,0x00,0x00);
ImageTTFText ($im, 20, 0, 10, 40, $black, 'courbi', 'The Courier TTF font');
header('Content-Type: image/png');
ImagePNG($im);
?>
No comments:
Post a Comment