Create PNG using PHP

I have a MySQL database and would like to have a script in PHP that for each row that the script is looking at, would be able to take the data and arrange them on the page at the given dimension on a newly created PNG or JPEG.  One of the fields in the database would point to an image saved on the server that I would also like to appear on the new image file (as part of the new image, NOT showing the link to the image).

How can this be done?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Use the GD library:

// Create a 500x400 image
$im = imagecreate(500,400);

// Allocate some colors
$background_color = imagecolorallocate($im, 255, 255, 255); // White
$text_color = imagecolorallocate($im, 0, 0, 0); // Black

// Write some text at 20 pixels from the left, 10 pixels from the top
imagestring ($im, 1, 20, 10, "Some text", $text_color);

// Write some more text at 60 pixels from the left, 10 pixels from the top
imagestring ($im, 1, 60, 10, "Column 2", $text_color);

// Write some more text at 60 pixels from the left, 10 pixels from the top
imagestring ($im, 1, 60, 10, "Column 2", $text_color);

// Create a PNG file
imagepng($im, "newimage.png");

// Show in the browser
print "<img src='newimage.png'>";

Yo ucan also use functions like imagecreatefrompng() and imagecopy() copy an existing image INTO the newimage.png image you are creating.

There's a LOT of ways to do this, but if you go to those links, you'll be able to  see all the different GD functions on the left-hand side. It's worth time to go through them and look at all the examples.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tru504187211Author Commented:
gr8gonzo - it appears that this will work, however, the solution to my problem is going to have to be a completely different route.  I do plan on using this function for a separate project I am working on, so THANK YOU!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.