Switch to full style
:read: Start PHP with us. Includes topics to help you in php
Post a reply

Fixed Space Using imageTTFbbox()

Sun Oct 26, 2008 11:02 pm

Code:
<?php
header
("Content-type: image/gif");
$height = 100;
$width = 200;
$fontsize = 50;
if ( ! isset (
$text ) )
    
$text = "www.codemiles.com";
$image = imagecreate( $width, $height );
$red = imagecolorallocate($image, 255,0,0);
$blue = imagecolorallocate($image, 0,0,255 );
$font = "ARIALBD.TTF";
$textwidth = $width;
$textheight;

while (
1 ){
    
$box = imageTTFbbox( $fontsize, 0, $font, $text );
    
$textwidth =  abs( $box[2] );
    
$textbodyheight = ( abs($box[7]) )-2;
    if (
$textwidth < $width - 20 )
        break;
    
$fontsize--;
}
$gifXcenter = (int) ( $width/2 );
$gifYcenter = (int) ( $height/2 );
imageTTFtext($image, $fontsize, 0,(int) ($gifXcenter-($textwidth/2)),(int)($gifYcenter+(($textbodyheight)/2) ),
             
$blue, $font, $text );
imagegif($image);
?>




Post a reply
  Related Posts  to : Fixed Space Using imageTTFbbox()
 simple example for fixed image     -  
 static vs fixed div position     -  
 (3.0.4) Skymiles Setting Fixed WIDTH     -  
 hi i need ppt for space mouse.     -  
 Fixed Quantity Inventory model Simulator (C++)     -  
 White space link example     -  
 Get Disk total space     -  
 preserve the white space with-in the body tag     -  
 Get disk free space for Unix-Linux in php     -  
 remove space ,trim strings from left side ,right side ,both.     -  

Topic Tags

PHP Graphics