Log in

View Full Version : Image create



joshua
08-29-2006, 10:47 PM
HI,
Can someone please help me to make an image and put some text into it with PHP. I want to make an image in order to secure my site, and i make a script that put a text to an image. The problem is that i cant put a special font to that text and i dont know how to make it like "~" the text, i don't wont to be a single orizontal text ...i want to make it ondulate Any suggestion will be appreciated! 10X;)

alexjewell
08-30-2006, 07:48 PM
Well, here's what I have:



header ("Content-type: image/png");
$image_text = "Sample Text";
$img_handle = ImageCreate (230, 20) or die ("Cannot Create image");
$back_color = ImageColorAllocate ($img_handle, 0, 10, 10);
$txt_color = ImageColorAllocate ($img_handle, 233, 114, 191);
ImageString ($img_handle, 31, 5, 5, $image_text, $txt_color);
ImagePng ($img_handle);


This creates an image with a black background and pink text.
It's simple, 230px by 20px.
Hope that at least gets you down the right path.

Make sure that there's no line breaks between the opening <? and the header("Content-type: image/png"); part.

Also, make sure GD is installed on your server.

blm126
08-31-2006, 10:25 PM
you mean like a CAPTCHA?

joshua
09-01-2006, 07:15 AM
Thanks! ...for your post. That script is good, but i try to use my own font and i change it a little bit. The problem that i had it was because i didn't write to the font url the all url from the home, for example i write "fontName.ttf" and i shoud write "/home/joshua/public_html/fontName.ttf" (i use Linux as OS). Thanks for you script!