|
Posted by David Robley on 01/10/06 08:40
The Doctor wrote:
> I get a customer that has the following code
> that needs to run:
>
> <?
> Header("Content-Type: image/gif");
>
> if(isset($_GET['BTT'])){
>
> $BTT = $_GET['BTT'];
> }
> else{
> $BTT = "";
> }
>
> $insert = imagecreatefromgif("MenuButton3.gif");
> $text=$BTT;
> $font="/Fonts/verdanab.ttf";
>
> // calculate position of text
>
> $tsize = ImageTTFBBox(10,0,$font,$text);
> $dx = abs($tsize[2]-$tsize[0]);
> $dy = abs($tsize[5]-$tsize[3]);
> $x = ( ImageSx($insert) - $dx ) / 2;
> $y = ( ImageSy($insert) - $dy ) / 2 + $dy;
>
> //choose textcolor (black)
>
> $col=ImageColorAllocate ($insert, 0, 0, 0);
> $black = imagecolorallocate($insert, 0, 0, 0);
> $grey = imagecolorallocate($insert, 128, 128, 128);
>
> //center text
> //work out how big the text is
> $bounds = imagettfbbox(10,0,$font,$text);
>
> //get width - right x coord - left x coord
> $textwidth = $bounds[2] - $bounds[0];
>
> //get offset
>
> $textoffset = $textwidth / 2;
>
> //calc start pos - half the image size minus offset - middle of image
> should be middle of text.
> $textstartpos = (imagesx($insert)/2) - $textoffset;
>
> // imagettftext ($insert, 10, 0,$textstartpos, 21, $grey $font, $text);
>
> imagettftext ($insert, 10, 0,$textstartpos, 18, $black, $font, $text);
>
> imagegif($insert,"",100);
> imagedestroy($insert);
>
> ?>
>
> Here is my php config:
>
> configure --prefix=/usr/contrib --localstatedir=/var \
> --infodir=/usr/share/info \
> --mandir=/usr/share/man --with-low-memory --with-elf --with-x \
> --with-mysql=/usr/contrib --with-zlib --enable-track-vars \
> --enable-versioning --with-config-file-path=/usr/contrib/lib \
> --with-gd --enable-ftp --with-openssl=/usr/contrib \
> --with-jpeg-dir=/usr --with-pgsql=/usr/contrib/pgsql \
> --with-png-dir=/usr --with-zlib-dir=/usr \
> --with-xpm-dir=/usr/X11R6 --with-libxml-dir=/usr/contrib/ \
> --with-freetype-dir=/usr/X11R6 --with-tsrm-pthreads --enable-mbstring \
> --enable-imap --with-bz2 --with-apxs2=/usr/contrib/bin/apxs
>
> What am I missing?
What is not happening that you expect to be happening? Or what is happening
that you expect not to happen? Are there any error messages?
Try removing the header call and check for any displayed errors.
Cheers
--
David Robley
Test-tube babies shouldn't throw stones.
Navigation:
[Reply to this message]
|