note 79530 added to function.imagettfbbox

From: Date: Sun, 02 Dec 2007 12:45:25 +0000
Subject: note 79530 added to function.imagettfbbox
Groups: php.notes 
Request: Send a blank email to php-notes+get-132735@lists.php.net to get a copy of this message
Simple Banner Maker Form: <center> <form name="cform" method="post" action="ini.php"> Title: <input style="border:1px solid; font-family:verdana; font-weight: bold" name="text" size="50"><br> <br> Line1: <input style="border:1px solid; font-family:verdana; font-weight:bold" name="text1" size="50"><br> <br> Line2: <input style="border:1px solid; font-family:verdana; font-weight:bold" name="text2" size="50"><br> <br> <INPUT TYPE="SUBMIT" name="submit" VALUE="Submit"> <INPUT TYPE="RESET" name="reset" VALUE="Reset"> </form> </font> </center> ini.php <?php // Get data from a form $textw = $_POST['text']; $textw1 = $_POST['text1']; $textw2 = $_POST['text2']; // Font type $font = 'vedrana.ttf'; $font1 = 'arial.ttf'; // Font size $fontsize = 28; $fontsize1 = 8; $fontsize2 = 9; // Add the text $text = $textw; // Text line 1 $text1 = $textw1; // Text line 2 $text2 = $textw2; //Box $box = imagettfbbox($fontsize, 0, $font, $text); $box1 = imagettfbbox($fontsize1, 0, $font, $text1); $box2 = imagettfbbox($fontsize2, 0, $font, $text2); //Find out the width and height of the text box $xsize = abs($box[0]) + abs($box[2]); $ysize = abs($box[1]) + abs($box[5]); $xsize1 = abs($box1[0]) + abs($box1[2]); $ysize1 = abs($box1[1]) + abs($box1[5]); $xsize2 = abs($box2[0]) + abs($box2[2]); $ysize2 = abs($box2[1]) + abs($box2[5]); //Create the image - 468 x 60 for this example $image = imagecreatefrompng("image/bg1.png"); //Get Image Size $imagesize = getimagesize("image/bg1.png"); //Text position $positiona = round(($imagesize[0] - $xsize) / 2); $positionb = round(($imagesize[1] + $ysize) / 2) ; $positionaa = round(($imagesize[0] - $xsize) / 2); $positionbb = round(($imagesize[1] + $ysize) / 2) - 3; $positiona1 = round(($imagesize[0] - $xsize1) / 14); $positionb1 = round(($imagesize[1] + $ysize1) / 4) - 3; $positiona2 = round(($imagesize[0] - $xsize2) / 1) - 9; $positionb2 = round(($imagesize[1] + $ysize2) / 2) + 14; ///Font color $color = ImageColorAllocate($image, 80, 80, 80); /// Shadow font color $color1 = ImageColorAllocate($image, 255,255,255); imagettftext($image, $fontsize, 0, $positiona, $positionb, $color, $font, $text); //// Add some shadow to the title text imagettftext($image, $fontsize, 0, $positionaa, $positionbb, $color1, $font, $text); // Text lines 1 and 2 imagettftext($image, $fontsize1, 0, $positiona1, $positionb1, $color, $font1, $text1); imagettftext($image, $fontsize2, 0, $positiona2, $positionb2, $color, $font1, $text2); header('content-type: image/png'); imagepng($image); imagedestroy($image); ?> ---- Server IP: 69.147.83.197 Probable Submitter: 89.216.212.12 ---- Manual Page -- http://www.php.net/manual/en/function.imagettfbbox.php Edit -- https://master.php.net/note/edit/79530 Del: integrated -- https://master.php.net/note/delete/79530/integrated Del: useless -- https://master.php.net/note/delete/79530/useless Del: bad code -- https://master.php.net/note/delete/79530/bad+code Del: spam -- https://master.php.net/note/delete/79530/spam Del: non-english -- https://master.php.net/note/delete/79530/non-english Del: in docs -- https://master.php.net/note/delete/79530/in+docs Del: other reasons-- https://master.php.net/note/delete/79530 Reject -- https://master.php.net/note/reject/79530 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#132735) next »