What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » PHP GD help

Pages: (2): « First [ 1 ] 2 » Last »
PHP GD help
Author: Message:
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. PHP GD help
I made a small code to make a random text-sig some while ago, and today I added Sign the Petition to it, but I realised it was too small to fit the text, so I made it double the size, but not it doesn't look nice with smaller texts anymore...


Anywaaaay, what im trying to ask is :P, can someone help me to make it auto-adjust the size to the text.

I already tried it with imagettfbox but couldn't get it to work. Because I don't think my server can use ttf font's, and I can't change any settings cause it's my hosting company's server.

TIA

And below my code :)

code:
<?php


//randomizer
srand((float) microtime() * 10000000);
$input = array("Ezra", "TSDME", "MsgPlus!", "Nintendo", "SPAM", "Web2Messenger", "Sign the Petition");
$rand_keys = array_rand($input, 2);
$string =  $input[$rand_keys[0]];

//Header info
header("Content-type: image/gif");

//
$im = @imagecreate(160, 20);
$background_color = imagecolorallocate($im, 100, 100, 100);
$text_color = imagecolorallocate($im, 000, 000, 200);

//
imagecolortransparent($im, $background_color);
imagestring($im, 5, 7, 3, $string, $text_color);
imagegif($im);
imagedestroy($im);

//statistics
include_once('connection.inc.php');
opendb();

$query = "SELECT * FROM stats";
$result = mysql_query($query);

while($row = mysql_fetch_array($result)){
$sts = ($row[stats]) + 1;
}

$sql = "UPDATE stats
           SET stats = '$sts'";
             
mysql_query($sql);
?>


[Image: 1-0.png]
             
09-08-2005 07:35 PM
Profile PM Web Find Quote Report
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: PHP GD help
imagettfbox is very picky with the font path. Firstly you should check your PHPinfo to see if freetext (2 if possible) is installed. :)

This post was edited on 09-08-2005 at 07:57 PM by KeyStorm.
09-08-2005 07:57 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: PHP GD help
Freetext is not installed, Gettext is installed not sure if that's any use to it, but it's called text so I thougt it might be worth telling :-)

And I have PHP4 and 5 btw, so I can also use PHP5only functions if needed.
[Image: 1-0.png]
             
09-08-2005 08:03 PM
Profile PM Web Find Quote Report
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: PHP GD help
Well... check if the GD section of any of both versions says something about fonts or ttf?

Do you get an error when you use that function and not change the headers to image?
09-08-2005 08:16 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: PHP GD help
Stupid Windows FTP, I needed to upload the .ttf file in binary mode, but somehow Windows transferred in ASCII mode or something, because when I forced Binary mode with FireFTP It worked :-)

Anywaay, still working on it, the text looks a bit strange, I'll see if I can make it better and to get the resizing to work :)

progress: http://scripts.tsdme.nl/randomgif.php
[Image: 1-0.png]
             
09-08-2005 11:02 PM
Profile PM Web Find Quote Report
brian
Senior Member
****

Avatar

Posts: 819
Reputation: 43
– / Male / –
Joined: Sep 2004
RE: PHP GD help
I don't like the font? Or is it my explorer?
09-08-2005 11:09 PM
Profile PM Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: PHP GD help
I don't like it either it's supposed to be arial, but it's buttugly right now :P

Anywaay, the resizing works :)

Now, I just need to make the font look nice :P

UH.... It's not showing on IE :S, it's just a GIF with transparancy...

Hmm, nvm, working now on IE :), crazy IE...


So does anyone know how to make it look nicer?

BTW: I still want a transparent background.

This post was edited on 09-09-2005 at 12:13 AM by Ezra.
[Image: 1-0.png]
             
09-08-2005 11:24 PM
Profile PM Web Find Quote Report
KeyStorm
Elite Member
*****

Avatar
Inn-sewer-ants-pollie-sea

Posts: 2156
Reputation: 45
38 / Male / –
Joined: Jan 2003
RE: PHP GD help
Gif will always do hard backgrounds.

Youy may use PNG.

[code]
$img = imagecreatetruecolor($width, $height)
imageAlphaBlending($img, true);
imageSaveAlpha($img, true);
imagecolorallocate($img,0,0,0,127);
[/color]

This will make a transparent backgrounded PNG

You must note that MSIE 6 is the only browser that does not support them. 7 is said to do.
09-09-2005 01:35 PM
Profile E-Mail PM Web Find Quote Report
Ezra
Veteran Member
*****

Avatar
Forgiveness is between them and God

Posts: 1960
Reputation: 31
37 / Male / Flag
Joined: Mar 2003
O.P. RE: PHP GD help
On the php.net pages it says I can't use imagesavealpha when imagealphablending is enabled :S

And I keep having a black background for some reason :s
[Image: 1-0.png]
             
09-09-2005 02:37 PM
Profile PM Web Find Quote Report
L. Coyote
Senior Member
****

Avatar
Captain Obvious

Posts: 981
Reputation: 49
39 / Male / Flag
Joined: Aug 2004
Status: Away
RE: PHP GD help
quote:
Originally posted by Ezra
And I keep having a black background for some reason
Are you using IE?

quote:
Originally posted by KeyStorm
You must note that MSIE 6 is the only browser that does not support them. 7 is said to do.

Hack, hack, hack!
Finally became a Systems Analyst! :spam:

09-09-2005 02:40 PM
Profile PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On