View Full Version : Make a Custom Gamercard-Like Generator Using PHP

12-13-2008, 01:52 AM
I've been pulling my hair out trying to do this, so I figured it was time for some help from the experts.

I am trying to create a PHP script that can generate an image with another image and some text in it that is selected from a database. Since this is quite hard to explain, I will use GamerCards as my example. If any of you have seen GamerCards before, you can see that they consist of one image that might have an avatar of some sort plus some other text that has been compiled into one image and is updated automatically.

Here is an example of a GamerCard that I made for Oblivion:


As you can see, the GamerCard-like image listed above contains a small image on the left that is chosen by the user when using the GamerCard generator coded in PHP. Also, you can see some other images and text placed in columns and rows throughout my example image above. Here are my biggest problems:

I need to develop a PHP script that allows a user to enter a URL for the image and enter some text for the other things listed in my GamerCard and, once the generator is submitted, have a new image created with all of the text compiled into one image.
I need it to be able to update automatically without creating a new URL when information in the database that is listed in the image is changed.

Please, I really need help here. If you do not understand what I am asking, feel free to ask me to elaborate on any of my points. I will very much appreciate any help that I get, and please ask me questions if you need to better understand my question. I don't mind taking it one step at a time to develop this script, I just want it developed, please. Thank you!

PS: If anyone can tell me how to use HTML in PHP arrays, that will help me just as much!

12-13-2008, 12:35 PM
I really don't quite understand myself. I thought you were talking about a Image Cache, but then it sounds like over lapping images, and inserting text.

12-13-2008, 05:59 PM
Well, have you ever seen those GamerCards? I would like to make a sort of GamerCard generator where a user types in a bunch of data in various input fields, uploads a small picture, and then submits the generator form and a .png image is created and stored in my webspace that has the image that the user uploaded plus all of the text that they typed in the input fields all placed on the image and complied into a .png file. Here is an example of a GamerCard generator so that you can get the idea of what I am trying to do: http://www.mygamercard.net (http://www.mygamercard.net/). As you can see there, it asks you for some information and then, once submitted, it generates an image called a GamerCard with other images and text compiled into it. Now, the website I showed you puts text and images in that GamerCard that have been taken from a database, but it's pretty much the same thing that I want to do.

I was using this tutorial (http://www.phpmix.org/how_to_create_a_dynamic_signature) to try to create an image with other text and images compiled into it. Maybe taking a quick look through that tutorial will give you an idea of what I am trying to accomplish. The problem that I had with that tutorial was that, although it allowed me to enter text and have it compiled into one .png image, it used PHP arrays to place the text in the image and I could not put HTML formatting into that image.

Maybe that will help you to better understand what I am asking. Thanks for your reply, by the way!

12-29-2008, 05:12 AM
I completely understand what your wanting. I have done the exact same thing, but instead it was a company profile image.

Tips for you.

Make sure all the 'Text' your having loaded into the image is stored in a Database.
For the images you allow them to upload, I would have converted into Base64 (using php) and store that into the database also.
I would write one master script that will be used to make ALL 'GamerCards', then you pull out the gamer card, use a URL like (script.php?GamerID=8656)
Make sure on that script to print your header for your image type, header('Content-Type: image/PNG');

Read This Chapter - http://us3.php.net/gd

If you read through that chapter, you will find what your doing is rather simple. Or at least I can be, I remember my first attempt was a little hard. the GD and MING extensions inside PHP happen to be my fav. So feel free to ask further questions.

PS.. you said something about (arrays), mmm thats candy to, what is your question on its usage? Arrays are your best friend, but without understanding them, their your worst friend.