GD - TF Image

Status
Not open for further replies.

Yek

T.F's Resident Cool Guy...
Messages
1,613
You may, (or may not) have noticed the image i use in the new members area now and again. I'm getting pretty quick at creating them but, let's face it, it's getting a tad tedious.

I'm wondering if someone could shed some light on this one ;)

Firstly, the codes.

PHP tfgenerate.php http://193.111.226.179/tfgenerate.php

Code of tfgenerate.php

Code:
<?php
header('Content-type: image/png');
$text = $_GET['text'];
$im = imagecreatefrompng ("tf.png");
$color = imagecolorallocate($im, 0, 0, 0);
$font = 'font.ttf';
$fontsize = 24;
$size = imagettfbbox($fontsize, 0, $font, $text); //calculate the pixel of the string
$dx = (imagesx($im)) - (abs($size[2]-$size[0])) - 20; //calculate the location to start the text
imagettftext($im, $fontsize, 0, $dx, 35, $color, $font, $text);
imagepng($im);
imagedestroy($im);
?>

The fonts and raw PNG are in their reletive locations.

Now, we all know where I need things to go :p

Heres a sample:

shadoweve.gif



Hoping CrazeD or someone can help me out ;)

Cheers,

~ Tkey
 
So, what are you trying to do exactly? You want to create an image like the one you posted using PHP?
 
yeah, I think iv got the basic code up there, just im not sure how to configure the colours and get it in the right place. It's definatly working since appending &text= works perfectly. Just..... in the wrong place :p
 
Could you get ahold of any infomation on this CrazeD, or do you need some more info from me?

Cheers,

~ Tkey
 
Try using this to smooth the text (not 100% sure if it works on text or not):
PHP:
imageantialias($im, true);

As for the rest, it should work like you use GET to retrieve the users name, and the generic statement that proceeds is already in the file.

Like:

PHP:
$allofthetext = "Hey ".$username.", Welcome to the forums..."
 
The text smoothing you suggested did nothing :(
I'm not quite sure why there is such a loss of quality, since the filetype is set to PNG and the file is a PNG.

Could this be something to do with the PHP running on my server?

Cheers,

~ Tkey
 
Sorry Tkey, been kind of busy.

And I still don't really know what you need help with. You seem to have code that works. Are you just trying to fix the fuzzy text?
 
Sorry. Yes, basically I need to image quality fixing, then I need to sort out the positioning and colours to mach those I use in the image normally.

Cheers,

~ Tkey
 
Ok, so what is tech forums.png that you reference? I don't know which parts are image and which parts are text.
 
Okay dont go off at me, but i cant actually get that code to work. I have GD installed and everything but it throws errors galore. But obviously, its working for you so ill try to help.

Try keeping the AntiAliasing code i have. Even if its doing nothing, it cant make things worse.

Next, swap

PHP:
imagettftext($im, $fontsize, 0, $dx, 35, $color, $font, $text);

for

PHP:
imagestring($im, 3, 0, 35, $text, $color)
The 3 is a generic font, you can later change it with $font if it still looks odd and try it once more.
 
Status
Not open for further replies.
Back
Top Bottom