note 39808 added to function.imagettfbbox

From: Date: Wed, 11 Feb 2004 12:55:24 +0000
Subject: note 39808 added to function.imagettfbbox
Groups: php.notes 
Request: Send a blank email to php-notes+get-65008@lists.php.net to get a copy of this message
the oliver dot martin at onemail dot fixbbox function is just lacking a small thing: the coordonates for top and left have to be the opposite, because the imagettftext x and y coordonates are calculated from the top left of the image and set the bottom left of the first character. The correct function is: 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]) + 1; $tmp_bbox["height"] = max($bbox[1],$bbox[3],$bbox[5],$bbox[7]) - min($bbox[1],$bbox[3],$bbox[5],$bbox[7]); $tmp_bbox["left"] = 0 - $tmp_bbox["left"]; $tmp_bbox["top"] = 0 - $tmp_bbox["top"]; return $tmp_bbox; } And it works for any rotated text. ---- Manual Page -- http://www.php.net/manual/en/function.imagettfbbox.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+39808 Delete -- http://master.php.net/manage/user-notes.php?action=delete+39808&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+39808&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#65008) next »