Creating graphics on the fly with php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
mintextra
Forum Newbie
Posts: 1
Joined: Wed Dec 08, 2010 5:52 am

Creating graphics on the fly with php

Post by mintextra »

Hello,

On my website I wish to have a simple graphic and allow users to write their own text onto the graphic then they can save out the graphic.

I'm new to PHP so I'm not that good at it. I've done some research and I think I need to use the GD library is this right?

What would be the easiest way to do what I want?

Thanks
mikecampbell
Forum Commoner
Posts: 38
Joined: Tue Oct 12, 2010 7:26 pm

Re: Creating graphics on the fly with php

Post by mikecampbell »

Here's something to get you started. Save it as a PHP file (eg called image.php) and then hit it on your server. You need to have GD enabled.

Code: Select all

<?php
$image = imagecreatetruecolor(60, 20);
$white = imagecolorallocate($image, 255, 255, 255);
imagestring($image, 3, 4, 4, "Hello!", $white);
header("Content-type: image/png");
imagepng($image);
?>
Post Reply