note 54000 added to function.imagechar

From: Date: Mon, 20 Jun 2005 15:35:46 +0000
Subject: note 54000 added to function.imagechar
Groups: php.notes 
Request: Send a blank email to php-notes+get-90699@lists.php.net to get a copy of this message
For the sake of completeness, here is an example for imagechar. The base-image automatically adjusts to the size and the height of the given string. Using the rand()-function the y-position of each char is slightly varied with every loop-run. You can easily rewrite the script to use a randomly generated string - the one given here just serves as an example. <?php $string = '1 2 3 4 5 6 7 8 9 A B C D E F G'; $font_size = 5; $width=imagefontwidth($font_size)*strlen($string); $height=imagefontheight($font_size)*2; $img = imagecreate($width,$height); $bg = imagecolorallocate($img,225,225,225); $black = imagecolorallocate($img,0,0,0); $len=strlen($string); for($i=0;$i<$len;$i++) { $xpos=$i*imagefontwidth($font_size); $ypos=rand(0,imagefontheight($font_size)); imagechar($img,$font_size,$xpos,$ypos,$string,$black); $string = substr($string,1); } header("Content-Type: image/gif"); imagegif($img); imagedestroy($img); ?> ---- Manual Page -- http://www.php.net/manual/en/function.imagechar.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+54000 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes&reason=non-english Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54000&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+54000&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#90699) next »