GDF image question

Started by a2h_, October 12, 2006, 08:13:41 PM

Previous topic - Next topic

a2h_

<?php
header
("Content-type: image/png");
$im = imagecreatetruecolor(290, 18);
$black = imagecolorallocate($im, 0, 0, 0);
$white = imagecolorallocate($im, 255, 255, 255);
imagefilledrectangle($im, 0, 0, 49, 19, $black);
$font = imageloadfont("arcade_n.gdf");
imagestring($im, $font, 10, 5, "ARCADE", $white);
imagepng($im);
?>


Is it possible to:

  • Make the background transparent
  • Be able to output input text instead of arcade via something like this:
    msg.php?msg=Nice%20day
  • Make the image stretch and shrink according to the amount of text

Please give me code as well if you know how to make one of those work. Thanks, because I would love to use this in my SMF Arcade mod!
With an underscore. Because the one without an underscore's taken.

SleePy

1. Only think its possible if the image already has transparency..

2. Add this just after the <?PHP

$msg = $_GET['msg'];


then change

imagestring($im, $font, 10, 5, "ARCADE", $white);


To this:

imagestring($im, $font, 10, 5, $msg, $white);


3. I think thats possible but would require a lot of work to find out how many characters the $msg variable is and adjust properly and for the orginal image to be that big..
Jeremy D ~ Site Team / SMF Developer ~ GitHub Profile ~ Join us on IRC @ Libera.chat/#smf ~ Support the SMF Support team!

a2h_

1. It doesn't use an image, so will I need a template image now?
2. Works, thanks
3. Maybe I'll just have to create a template image for each expected string
With an underscore. Because the one without an underscore's taken.

kegobeer

You should check out the PHP GD image functions.  Transparency can be set for colors.

http://us3.php.net/manual/en/function.imagecolortransparent.php
"The truth of the matter is that you always know the right thing to do. The hard part is doing it." - Norman Schwarzkopf
Posting and you (Click "WATCH THIS MOVIE")

a2h_

#4
Thanks for all the help, I've googled a PHP tutorial for if, and found else and elseif tutorials.

With an underscore. Because the one without an underscore's taken.

Advertisement: