Page 1 of 1

Generate images on the fly

Posted: Sun Nov 06, 2005 11:20 pm
by waradmin
Ive seen this done before, even had a script at one time but lost it, so ill ask it here (i did search and found nothing). I want to generate images with custom text on them. So for example image.php?size=2&text=sweet or whatever.

For people who know a lot about php that probably isnt that hard. But i also (if possible) want it to look something like the header on my blog (http://www.open-server.org). I dont know if that is possible or not but i would like anyones help who can offer ideas. I have the font downloaded for the banner on my site, and i would like to be able to automaticly generate the text on it on the fly for the blog hosting service i run that way people can have custom banner images.

Thanks in advance.

Posted: Sun Nov 06, 2005 11:46 pm
by feyd
study and play around with the gd functions..

Posted: Mon Nov 07, 2005 2:51 am
by onion2k

Posted: Mon Nov 07, 2005 3:05 am
by phpdevuk
this sounds like the sort of thing your after http://www.alistapart.com/articles/dynatext/

Posted: Mon Nov 07, 2005 4:20 am
by Jenk

Code: Select all

<?php

$size = (isset($_GET['size']) ? intval($_GET['size']) : ''); /* change '' to default size */
$text = (isset($_GET['text']) ? strval($_GET['text']) : ''); /* change '' to default text */

$image = imagecreate(300, 300); /* create image 300pix by 300pix */
$background = imagecolorallocate($image, 255, 255, 255); /* white background */
$textcolour = imagecolorallocate($image, 0, 0, 0); /* black text */

imagestring($image, $size, 0, 0, $text, $textcolour);

header('Content-Type: image/png');
imagepng($image);
imagedestroy($image);

?>
off the top of my head :)

Posted: Mon Nov 07, 2005 11:37 am
by waradmin
The easiest one is Jenks. How would i use custom fonts with that, and colors. Or is that not possible. Thanks.