*.png - wrapping text

From: Date: Fri, 09 Nov 2001 05:12:50 +0000
Subject: *.png - wrapping text
Groups: php.general 
Request: Send a blank email to php-general+get-73995@lists.php.net to get a copy of this message
I'm playing with some code to put text on an image: http://www.collegeSherbrooke.qc.ca/languesmodernes/course/image/marc.php Because I'm using a fixed font, I know I don't want to go over 34 characters per line. I calculate my maximum number of chatraacters to be 476. How can I parse $string to "wrap", keeping in mind spaces between words and the occasional \n that $string might contain? I know it would have somethig to do with strlength and exploding to count spaces, but ... ? Thanks, John Here is the code I am playing with: <?php Header("Content-type: image/png"); // $string=implode($argv," "); $string="1234567890123456789012345678901234"; // $string=urldecode($string); $im = imagecreatefrompng("button1.png"); $orange = ImageColorAllocate($im, 255, 0, 64); $px = (imagesx($im)-7.5*strlen($string))/2; //image //font built-in //position x //position y //string //colour // ImageString($im,3,$px,9,$string,$orange); ImageString($im,3,241,30,$string,$orange); ImageString($im,3,241,40,$string,$orange); Imagepng($im); ImageDestroy($im); ?>

« previous php.general (#73995) next »