note 38880 deleted from function.imagettfbbox by cmb
| From: | cmb@php.net | Date: | Sun, 04 Dec 2016 12:00:57 +0000 |
| Subject: | note 38880 deleted from function.imagettfbbox by cmb | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-208171@lists.php.net to get a copy of this message | ||
Note Submitter: oliver dot martin at onemail dot at
----
The original fixbox function by <php at deathz0rz dot homeunix dot net> doesn't work when
the text is rotated, as it assumes that the upper left corner of the text is also the upper left
corner of the bounding box. Same goes for the lower right corner. Here is my corrected version of
it:
<?
function fixbbox($bbox)
{
$tmp_bbox["left"] = min($bbox[0],$bbox[2],$bbox[4],$bbox[6]);
$tmp_bbox["top"] = min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
$tmp_bbox["width"] = max($bbox[0],$bbox[2],$bbox[4],$bbox[6]) -
min($bbox[0],$bbox[2],$bbox[4],$bbox[6]);
$tmp_bbox["height"] = max($bbox[1],$bbox[3],$bbox[5],$bbox[7]) -
min($bbox[1],$bbox[3],$bbox[5],$bbox[7]);
return $tmp_bbox;
}
?>
However, be aware that this might not be very useful, as gd-2.0.8 introduces a bug which renders the
results of imagettfbbox() useless when the text is rotated. This is still not fixed in the the
php-4.3.4 bundled version (2.0.15 compatible).