Jump to content
xisto Community
rejected

Write Random Text To Image PHP script help

Recommended Posts

I'm trying to create a script that writes text to an image.

header("Content-type: image/png");$_phrases = array("Test 1","Test 2","Test 3","Test 4","etc.");$_rand_phrase = $_phrases[rand(0,count($_phrases)-1)];$_image = imagecreatefrompng("gmail.png");$_user_width = imaagettfbbox(9,0,"tahoma.ttf",$_rand_phrase);$_x_value = (200-($user_width[2] + 113));$_color = imagecolorallocate($_image, 165, 164, 164);imagettftext($_image, 9, 0, $_x_value, 16, $_color, "tahoma.ttf", $_rand_phrase);imagepng($_image);imagedestroy($_image);
I can't see what I'm doing wrong.. I know it should work, I'm making a dumb mistake of some sort.

Can anyone help?

Share this post


Link to post
Share on other sites

I just made a similar script for a friend, one of those interactive sigs with the IP and all that on it. Anyway, try using

imagestring($_image, 3, 6, 6, $Title, $clr_black);//It works like this:imagestring($_image, FONT, X-POSITION, Y-POSITION, TEXT-TO-DISPLAY, COLOUR);

rather than imagettftext.

Also, try removing the _ from the variables as I have seen that confuse some set ups of PHP before.

What exact error do you get when you run the script, or do you just get a blank page?

Share this post


Link to post
Share on other sites

Thanks, about to try rvalkass's and then if it fails I'll try that tutorial Nguyen.There isn't an error, it just says that the iamge can't be displayed because it was errors.

Share this post


Link to post
Share on other sites

Sorry about that...darn edit button..I'll only call you Nguyen if allowed..if not I'll call you Guy B)And thanks for the link to the tut, it helped me fix one of my problems :P

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.