...

View Full Version : php image generation?



Ranger56
08-22-2006, 03:21 AM
Is it possible with php to create an image from a font on the server? something like


<img src="images/name.php?name=Someone">

And "Someone" would be an image?

boeing747fp
08-22-2006, 04:22 AM
yes it is possible.

to create an image from an image with name "someone"....
file: images/name.php....


<?php
header("Content-Type: image/jpeg");
$im = imagecreatefromjpeg($_GET['name']);
imagejpeg($im);
?>


if you meant have the image just output the name that is in ?name=Someone with a custom font, do this in images/name.php

<?php
header("Content-Type: image/jpeg");
$im = imagecreatetruecolor(100, 30); //100x30
$color = imagecolorallocate($im, 0, 0, 0); //black text
$font = imageloadfont("FONT FILE HERE");
imagestring ($im, $font, 0, 0, $_GET['name'], $color);
imagejpeg($im);
?>

Ranger56
08-22-2006, 04:48 AM
Thanks, I'll try it.

I tried
<?php
header("Content-Type: image/jpeg");
$im = imagecreatetruecolor(100, 30); //100x30
$color = imagecolorallocate($im, 0, 0, 0);
$font = imageloadfont("jiczyn.ttf");
imagestring ($im, $font, 0, 0, $_GET['name'], $color);
imagejpeg($im);
?>


And all it does it put the url on the page.

Link: http://www.spiderseatbabies.com/hate/name.php

boeing747fp
08-22-2006, 05:06 AM
create a separate page not named name.php and put


<img src="name.php?name=ME">

and try to access to new page

Ranger56
08-22-2006, 05:07 AM
http://www.spiderseatbabies.com/hate/test.html

Doesn't work.

:(

Fumigator
08-22-2006, 05:17 AM
Worked for me, but I didn't try loading my own font. Try a default font first.

My test (http://www.camelotguilds.org/textimg.htm)

Ranger56
08-22-2006, 05:24 AM
Still doesn't work for me...



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum