note 36697 added to function.imagettfbbox

From: Date: Sun, 19 Oct 2003 06:34:05 +0000
Subject: note 36697 added to function.imagettfbbox
Groups: php.notes 
Request: Send a blank email to php-notes+get-58867@lists.php.net to get a copy of this message
Ok, I got my script so far but i been trying to add positioning text so i can put it anywhere on the business card. Code: <?php error_reporting(E_ALL); $fields = array(array('Company Name: ', 'company', 20, array(0, 0, 0)), array('Company Message: ', 'message', 17, array(64, 128, 208)), array('Full Name: ', 'name', 20, array(255, 255, 255)), array('Job Title: ', 'title', 16, array(255, 255, 255)), array('Address Line 1: ', 'line1', 17, array(255, 255, 255)), array('Address Line 2: ', 'line2', 17, array(255, 255, 255)), array('Address Line 3: ', 'line3', 17, array(255, 255, 255)), array('Phone / Other: ', 'phone', 17, array(255, 255, 255)), array('Fax / Other: ', 'fax', 17, array(255, 255, 255)), array('E-mail / Other: ', 'email', 17, array(255, 255, 255)), array('Web / Other: ', 'web', 17, array(255, 255, 255))); function input($text, $name) { echo $text, '<input type="text" name="', $name, '" value="'; if(isset($_SESSION[$name])) echo $_SESSION[$name]; echo '" />', "\n"; } function drawstring($string, $diff, &$y, $font, $size, $color, $align = 'right') { global $image; if(is_int($font)) { $x = $diff; for($i = 1; $i < strlen($string); ++$i) { imagechar($image, $font, $x, $y, $string{$i}, $color); $x += imagefontwidth($font); } $y += imagefontheight($font); } else { $arr = imagettfbbox($size, 0, $font, $string); //left ////////////////////////////////// $width = $arr[2] - $arr[0]; switch($align) { case 'right': $x = imagesx($image) - $width - $diff; break; case 'center': $x = imagesx($image) / 2 - ($width / 2); break; case 'left': default: $x = $diff; break; } imagettftext($image, $size, 0, $x, $y + ($arr[1] - $arr[7]), $color, $font, $string); $y += $arr[1] - $arr[7] + 1; } } session_start(); if(isset($_GET['image'])) { $colors = array(); $image = imagecreatetruecolor(510, 295); $white = imagecolorallocate($image, 255, 255, 255); $im = imagecreatefrompng('backgrounds/' . $_SESSION['img'] . '.png'); imagecopy($image, $im, 0, 0, 0, 0, 510, 295); $y = 90; //Top ============================================= Had to cut some off ---- Manual Page -- http://www.php.net/manual/en/function.imagettfbbox.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36697 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36697&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36697&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58867) next »