php, get text from url and stuff it into a gif

Soldato
Joined
6 Jun 2006
Posts
6,012
Location
Kent
I've been trying to get this to work for what seems like an eternity with no luck.

I've tried imagecreatefromgif using a blank gif and get_file_contents, but that just gives a broken image.

I'm using smarty to create the text, is there someway to make the image in smarty too? My GoogleFu sucks for these kinds of things. The reason for using smarty to create some text, you may ask? I need the text to update when it's requested rather than doing it manually. But I'm kinda thinking as soon as I put this into an image, it'll become static again unless I write a shell script to flush the image and make a new one.

URL of the text in question is here.

Or, even better, is there some way I can masquerade the text as an image for a forum signature? Currently, it gives the broken image icon.

Any help on where I'm going wrong would be very much appreciated as this has been bugging me for a while! Thanks.
 
i know nothing about smarty so can't help with that.

but using $file_get_contents will get the text on every page load anyway. it won't cache anything unless you specifically set that up yourself. the image will be generated dynamically on the fly every time.

you need to be looking at the various GD functions on the php manual pages.

imagecreatetruecolor (to create a new blank image. use imagecreatefrom.... if you already have a background image you want to use)
imagefillrectangle (to fill in a background colour if creating a new image)
imagecolorallocate (to define colours)
imagettftext (to write the text into the image. you can use any truetype font with this)
imagejpeg/imagegif to output your created image on screen

(some people might suggest using image magick instead of GD but i don't know how to use that :p)
 
Back
Top Bottom