note 87759 added to function.imagestring

From: Date: Fri, 19 Dec 2008 20:07:56 +0000
Subject: note 87759 added to function.imagestring
Groups: php.notes 
Request: Send a blank email to php-notes+get-148371@lists.php.net to get a copy of this message
I created an alternative using the function imagechar to create a string of an image. The below function below was used to create an image the same height and width of the text string. It is used on my website (http://www.beatspot.co.uk) to mask users email addresses. <?PHP // Set your string somehow $string = 'your@email.com'; // Set font size $font_size = 4; // Create image width dependant on width of the string $width = imagefontwidth($font_size)*strlen($string); // Set height to that of the font $height = imagefontheight($font_size); // Create the image pallette $img = imagecreate($width,$height); // Grey background $bg = imagecolorallocate($img, 25, 25, 25); // White font color $color = imagecolorallocate($img, 255, 255, 255); // Length of the string $len = strlen($string); // Y-coordinate of character, X changes, Y is static $ypos = 0; // Loop through the string for($i=0;$i<$len;$i++){ // Position of the character horizontally $xpos = $i * imagefontwidth($font_size); // Draw character imagechar($img, $font_size, $xpos, $ypos, $string, $color); // Remove character from string $string = substr($string, 1); } // Return the image header("Content-Type: image/gif"); imagegif($img); // Remove image imagedestroy($img); ?> ---- Server IP: 92.48.74.199 Probable Submitter: 150.204.48.100 ---- Manual Page -- http://www.php.net/manual/en/function.imagestring.php Edit -- https://master.php.net/note/edit/87759 Del: integrated -- https://master.php.net/note/delete/87759/integrated Del: useless -- https://master.php.net/note/delete/87759/useless Del: bad code -- https://master.php.net/note/delete/87759/bad+code Del: spam -- https://master.php.net/note/delete/87759/spam Del: non-english -- https://master.php.net/note/delete/87759/non-english Del: in docs -- https://master.php.net/note/delete/87759/in+docs Del: other reasons-- https://master.php.net/note/delete/87759 Reject -- https://master.php.net/note/reject/87759 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#148371) next »