Forum Home
Press F1
 
Thread ID: 76634 2007-02-07 21:28:00 Creating image of text using php Morgenmuffel (187) Press F1
Post ID Timestamp Content User
523579 2007-02-07 21:28:00 Hi all

Situation is this

A client wants to put captions on her images (in jpg format) that will be used in a slideshow
This needs to be done on the server

my plan was to have her enter the relevant text press enter and the text would be written on to a gif with a semitransparent background which would then be added to the bottom of her image (jpg)

I know i have explained badly but basically the end result should look like this (nigel.geek.nz)

Thing is i have no idea how to ....


convert text to an image
put the resulting image Gif on to a jpeg and keep the semitransparent background of the gif so the jped shows through a little


any help would be appreciated
Morgenmuffel (187)
523580 2007-02-07 21:43:00 1) Screenshot and paste into your image editor.
2) Use something like Pictureshark (free).
Greg (193)
523581 2007-02-07 21:56:00 What is the intended use for the images? Is the slideshow going to be run in a web browser? If so, then I recommend you use CSS rather than altering the images to achieve the effect - it's a lot faster, and takes a fair bit of processing load off the server. The effect will render in all major browsers except Konqueror/Safari. The CSS tags needed are position, z-index, and the three browser-specific opacity tags.

If you must alter the images themselves, then PHP has a built-in graphics library called 'gd' that will do what you want. Alternatively, you can use a plugin library for something like ImageMagick.
Erayd (23)
523582 2007-02-07 22:46:00 I recommend you use CSS rather than altering the images to achieve the effect - it's a lot faster, and takes a fair bit of processing load off the server. The effect will render in all major browsers except Konqueror/Safari. The CSS tags needed are position, z-index, and the three browser-specific opacity tags.

If you must alter the images themselves, then PHP has a built-in graphics library called 'gd' that will do what you want. Alternatively, you can use a plugin library for something like ImageMagick.Riiiight. So he has to ask the questions but suddenly knows how to use CSS and PHP's GD? :lol:
Greg (193)
523583 2007-02-07 22:52:00 blog.neatlysliced.com Rob99 (151)
523584 2007-02-08 01:03:00 Riiiight. So he has to ask the questions but suddenly knows how to use CSS and PHP's GD? :lol:You got it. The reasoning for my logic was this:

1. The processing 'needs to be done on the server' - by 'server' I am assuming he is meaning a webserver in this case, and the client's uploading images to it.

2. As the processing must be done on the server, some kind of CGI is required - and seeing as PHP is installed on most webservers, he most likely has access to GD.

3. If he is responsible for a website that drives all this, then he likely knows CSS. However as I have run into a lot of people that 'know CSS' but don't know how to use some of the newer CSS2 techniques, I mentioned which tags were required.

4. If he doesn't understand it, he can ignore it - better to make a suggestion that _might_ be helpful than to shut up and let him be told it's not possible.
Erayd (23)
523585 2007-02-08 01:06:00 [could some mod remove this please? - irrelevant post] Erayd (23)
523586 2007-02-08 01:33:00 Ok thanks for the suggestions, just realized a left out some rather important parts of the equation, (you sometimes forget that not everyone is in the same room as you).

the images are going to be used by an existing flash slideshow that is controlled with an XML file, basically the customer wants simple captions on the image (like the one displayed earlier).

I want this done on the server mainly because i can control and to a certain extent idiot proof the process of adding new images, making the caption sizes and fonts standard so the slideshow looks at least moderately coherent

CSS is also out as I don't want to figure out how to get CSS styles working inside a Flash window and also because about 10% of the sites users are using IE 5 browsers which from memory had hopeless CSS support, I do use CSS on other parts of the site but mainly limit it to the really basic stuff

I am planning on using the GD or imagemagic libraries as they are both installed, but i have never turned text into an image and I am really unsure of how to add the caption to the image and retain the required transparency
I can't seem to find a tutorial that explains this in baby steps or at least clear english
Morgenmuffel (187)
523587 2007-02-08 01:43:00 www.php.net
www.scriptplayground.com

And I think you can get phpThumb() which will do it for you: http://phpthumb.sourceforge.net/
(Note that using phpThumb to do stuff with images on the fly would probably be quite heavy on the server. But I think you can get phpThumb() to write to a file as well, so it won't be on the fly)
mejobloggs (264)
1