note 52797 added to function.imagestring

From: Date: Thu, 12 May 2005 17:52:58 +0000
Subject: note 52797 added to function.imagestring
Groups: php.notes 
Request: Send a blank email to php-notes+get-89346@lists.php.net to get a copy of this message
Based on the previous example, here's how to center a string both horizontally and vertically... <?php function imagestringcentered ($img,$font,$text,$color) { while (strlen($text) * imagefontwidth($font) > imagesx($img)) { if ($font > 1) { $font--; } else { break; } } $cy = (imagesy($img)/2) - (imagefontwidth($font)/2); imagestring($img,$font,imagesx($img) / 2 - strlen($text) * imagefontwidth($font) / 2,$cy,$text,$color); } ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagestring.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52797 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52797&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52797&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52797&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52797&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52797&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52797&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89346) next »