Page 1 of 1

Creating graphics on the fly with php

Posted: Wed Dec 08, 2010 5:55 am
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

Re: Creating graphics on the fly with php

Posted: Wed Dec 08, 2010 2:10 pm
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);
?>