What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



imagepstext — Displays PostScript text.


array imagepstext(image, text, font, size, foreground, background, X, Y[, spacing][, tightness][, angle][, anti-aliasing]);
int image: Image identifier
string text: Text to display
int font: Font identifier
int size: Font size in pixels
int foreground: Color of text
int background: Background color to anti-alias into
int X: X coordinates
int Y: Y coordinates
int spacing (optional): Font spacing
int tightness (optional): Font tightness
double angle (optional): Angle of rotation
int anti-aliasing (optional): Anti-aliasing steps


Array of bounding-box coordinates


Writes text on an image using the Type1 PostScript font specified by the font identifier. A number of parameters in this function require explanation.

The foreground and background colors are used for anti-aliasing, and it's a good idea to specify the same color for the text background as the background of the image so the anti-aliasing works correctly. You can create a halo text effect by specifying a different background color.

The X and Y coordinates define where the first character is drawn. This is taken from the lower-left corner of the first character.

spacing and tightness specify the distance between words and letters. spacing refers to the size of the space between words; tightness refers to the spacing between individual letters. These are expressed in character space units, where 1 unit is 1/1000th of an em-square.

Anti-aliasing refers to the smoothing of round text edges. There are only two values for this, 4 and 16, which refer to low and high, respectively. If you're using smaller font sizes, use a value of 16. For large font sizes, use 4. Although you can use either size at any time, a small font size with less anti-aliasing yields poorer text quality; a high anti-alias value with large text can be computationally expensive.

The array returned contains the coordinates of the bounding box surrounding the text. The coordinate numbering starts relative to the lower left of the text and moves to the upper right.

0 lower-left x coordinate
1 lower-left y coordinate
2 upper-right x coordinate
3 upper-right y coordinate


Existing since version 3.0.9


Example 439. Display text

header("content-type: image/png");
$text="hello world";
$font = imagepsloadfont("/path/to/font.pfb");
$im = imagecreate(200, 200);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
$green = imagecolorallocate($im, 0, 255, 0);
imagefill($im, 0, 0, $black);
$bound = imagepstext($im, $text, $font, 25, $white, $green, 10, 100, 0, 0, 0, 4);
imagestring($im, 2, 10, 10, "x1 " . $bound[0], $white);
imagestring($im, 2, 10, 20, "y1 " . $bound[1], $white);
imagestring($im, 2, 10, 30, "x2 " . $bound[2], $white);
imagestring($im, 2, 10, 40, "y2 " . $bound[3], $white);

PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.