PhpDig.net

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




imagepsbbox

Name

imagepsbbox — Determines the coordinates of the area surrounding a text string.

Synopsis

array imagepsbbox(text, font[, space][, tightness][, angle]);
string text: Text string to use
int font: Font identifier
int space (optional): Distance between words
int tightness (optional): Spacing between letters
double angle (optional): Angle of rotation

Returns

Array of bounding box coordinates

Description

While similar to imagepstext() , this function doesn't actually draw any text. Instead, the text string is drawn "virtually," and the bounding box coordinates are returned without the text being drawn on the image. This means that calculations can be done on the text dimensions before committing it to the image, in case scaling is needed. The table below shows which elements of the array correspond to portions of the text bounding box.

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


Version

Existing since version 3.0.9

Example

Example 432. Display bounding box coordinates

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);
imagefill($im, 0, 0, $black);
$bound = imagepsbbox($text, $font, 25, 0, 0, 0);
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);
imagepng($im);
imagedestroy($im);



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 http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ 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.