Jump to content

Text to picture Generator


Zneeky

Recommended Posts

Hello, i have found this script and it works really good^^ But i have one problem, i would like to change the font and font size. Is there anyone here that know what code i should edit/paste in there?

 

Demo: http://fastbanner3.sroinfo.com/

 

 

Banner.php

<?php
$select_banner = $_POST["select_banner"];
$titletext = $_POST["titletext"];
$titlecolor = $_POST["titlecolor"];
$titlex = $_POST["titlex"];
$titley = $_POST["titley"];
$tagtext = $_POST["tagtext"];
$tagcolor = $_POST["tagcolor"];
$tagx = $_POST["tagx"];
$tagy = $_POST["tagy"];

if ((isset($titletext) || $titletext > "")
	and (isset($tagtext) || $tagtext > "")) {
$titlecolor = substr($titlecolor, -6);
$r1 = hexdec(substr($titlecolor, 0, 2));
$g1 = hexdec(substr($titlecolor, 2, 2));
$b1 = hexdec(substr($titlecolor, 4, 2));
$tagcolor = substr($tagcolor, -6);
$r2 = hexdec(substr($tagcolor, 0, 2));
$g2 = hexdec(substr($tagcolor, 2, 2));
$b2 = hexdec(substr($tagcolor, 4, 2));
$titletext2 = stripslashes($titletext);
$tagtext2 = stripslashes($tagtext);
$image = imagecreatefrompng("banner/$select_banner");
$titlecolor = imagecolorallocate($image, $r1, $g1, $b1);
$tagcolor = imagecolorallocate($image, $r2, $g2, $b2);
ImageString($image, 10, $titlex, $titley, $titletext2, $titlecolor);
ImageString($image, 10, $tagx, $tagy, $tagtext2, $tagcolor);
$counterval = 0;
$filename = "banners/counter.txt";
$fp = fopen($filename, "r");
$counterval = fread($fp, 26);
fclose($fp);
$counterval = (integer)$counterval + 1;
$fp = fopen($filename, "w+");
fwrite($fp, $counterval, 26);
fclose($fp);
$newbanner = 'banners/' . $counterval . '.png';
ImagePNG($image, $newbanner);
include("header.inc");
echo "\n";
echo "<a href=\"$newbanner\"><img src=\"$newbanner\" width=\"468\" height=\"60\" alt=\"Your Generated Banner\" border=\"0\"></a>\n";
echo "\n\n";
include("footer.inc");
} 
if ($counterval > 5) {
$deletebanner = (integer)$counterval - 5;
$delete = 'banners/' . $deletebanner . '.png';
unlink("$delete");
} 

?>

 

 

index.php

<?php
include("header.inc");

?>
<script type="text/javascript">
<!--

function showimage() {
if (!document.images)
return
document.images.banner.src=
'banner/' + document.fastbanner.select_banner.options[document.fastbanner.select_banner.selectedIndex].value
}

//-->
</script>
<script type="text/javascript">
<!-- Begin
function showColor(val) {
document.fastbanner.titlecolor.value = val;
}
function showColor2(val2) {
document.fastbanner.tagcolor.value = val2;
}
//  End -->
</script>

<div align="center">
<TABLE summary="table" cellspacing="0" cellpadding="0" width="100%">
<form action="banner.php" name="fastbanner" method="post">
      <TR>
        <TD align="center">
<table cellspacing="0" cellpadding="0" width="100%">

<tr>
       <td width="20%" aign="top">
   		<TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
                  <TR>
                    <TD class="border">
                      <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%">
                        <TR>
                          <TD colspan="1" class="header">
                            Instructions
                          </TD>
                        </TR>
                        <TR>
                          <TD class="main" colspan="4">
&#149; Select the banner to edit.<BR>
<BR>
&#149; Enter Title and Tag Line as this will be the text that will be on your banner.<BR>
<BR>
&#149; Choose your Title and Tag Line colors.<BR>
<BR>
&#149; Choose your Title and Tag Line coordinates. You can click the banner where you want the text to see the coordinates to use.<BR>
<BR>
&#149; Submit the information and your banner will be created.
                          </TD>
                        </TR>
                      </TABLE>
                    </TD>
                  </TR>
                </TABLE>
   </td>
   <td width="5%"> </td>
       <td width="75%">
   
   			  <TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
                  <TR>
                    <TD class="border">
                      <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%">
                        <TR>
                          <TD colspan="5" class="header">
                            Select Your Banner.
                          </TD>
                        </TR>
                        <TR>
                          <TD class="main" colspan="5" align="center">
<select name="select_banner" onChange="showimage()">
<?php
$open = opendir("banner");
while ($files = readdir($open)) {
$filename = $files;
if ($filename == "."){
print "\n";
}
elseif ($filename == ".."){
print "\n";
}
else {
print "<option value=\"$filename\">$filename</option>\n";
}
} 
?>
</select><br>
    <table cellspacing="0" cellpadding="0" width="484" summary="Banner Table">
      <tr>
        <td rowspan="2"><img src="Yscala1.gif" width="16" height="79" border="0" alt=" " /></td>
        <td><img src="Xscala1.gif" width="468" height="15" border="0" alt=" " /></td>
      </tr>
      <tr>
        <td valign="top"><img ismap onclick="alert('Coordinates:\n\nX POS: '+self.event.offsetX+'\nY POS: '+self.event.offsetY);" name="banner" src="banner/ban01.png" width="468" height="60" /></td>
      </tr>
    </table>
                          </TD>
                        </TR>
                      </TABLE>
                    </TD>
                  </TR>
                </TABLE><br>
<TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
                  <TR>
                    <TD class="border">
                      <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%">
                        <TR>
                          <TD colspan="1" class="header">
                            Pick your title text.
                          </TD>
                        </TR>
                        <TR>
                          <TD class="main" colspan="4">
                            <table cellspacing="0" cellpadding="0" width="100%">

<tr>
<td width="100"><input name="titletext" value="YourSite" size="43" maxsize="80"></td><td><INPUT type="text" size="7" name="titlecolor" maxlength="7" value="#009900"></td>
</tr>
<tr>
<td>
<map name="colmap">
<area shape="rect" coords="1,1,7,10" href="javascript:showColor('#00FF00')">
<area shape="rect" coords="9,1,15,10" href="javascript:showColor('#00FF33')">
<area shape="rect" coords="17,1,23,10" href="javascript:showColor('#00FF66')">

</map>
<img usemap="#colmap" src="colortable.gif" border=0 width=289 height=67>

</td>
<td><input name="titlex" type="text" value="54" size="3" maxsize="3">X Coordinates<br>
<input name="titley" type="text" value="10" size="3" maxsize="2">Y Coordinates</td>
</tr>
</table>

                          </TD>
                        </TR>
                      </TABLE>
			</TD>
                  </TR>
                </TABLE><br>
			<TABLE summary="table" cellspacing="0" cellpadding="0" border="0" width="100%" align="center">
                  <TR>
                    <TD class="border">
                      <TABLE summary="table" border="0" cellspacing="1" cellpadding="3" width="100%">
                        <TR>
                          <TD colspan="1" class="header">
                            Pick your tag text.
                          </TD>
                        </TR>
                        <TR>
                          <TD class="main" colspan="4">
                            <table cellspacing="0" cellpadding="0" width="100%">
<tr>
<td width="100"><input name="tagtext" value="This is my tagline." size="43" maxsize="80"></td><td><INPUT type="text" size="7" name="tagcolor" maxlength="7" value="#009900"></td>
</tr>
<tr>
<td>
<map name="colmap2">
<area shape="rect" coords="1,1,7,10" href="javascript:showColor2('#00FF00')">
<area shape="rect" coords="9,1,15,10" href="javascript:showColor2('#00FF33')">

</map>
<img usemap="#colmap2" src="colortable.gif" border="0" width="289" height="67">

</td>
<td><input name="tagx" type="text" value="54" size="3" maxsize="3">X Coordinates<br>
<input name="tagy" type="text" value="30" size="3" maxsize="2">Y Coordinates</td>
</tr>
</table>

                          </TD>
                        </TR>
                      </TABLE>
                    </TD>
                  </TR>
                </TABLE>
			</TD>
                  </TR>
                </TABLE>
   
   </td>
</tr>
</table>

              </TD>
            </TR>
          </TABLE>
	  <input type="submit" value="Create"> <input type="reset" value="Reset">
        </TD>
      </TR>
  </form>
    </TABLE>


			<br>Powered by FastBanner version 3<br>Copyright 2003 <a href="http://www.templatesforall.com">Templates For All</a>.<br>Since install FastBanner has generated <?php include("banners/counter.txt");
?> banner<?php
$filename = "banners/counter.txt";
$fp = fopen($filename, "r");
$count = fread($fp, 26);
fclose($fp);
if ($count > 1) {
print("s");
} elseif ($count == 0) {
print("s");
} 

?>.
               
</div>

<?php
include("footer.inc");

?>

 

[attachment deleted by admin]

Link to comment
https://forums.phpfreaks.com/topic/187874-text-to-picture-generator/
Share on other sites

This is from a script I wrote that makes a weather graphic. It assumes the font as a ttf is in the same folder but a path to the font will work.

 

$font = 'arial.ttf';

ImageTTFText($image, $fontSize, $fontRotation, $x_pos, $y_pos, $colorRed, $font, "$windchill_f&#186;F");

 

 

HTH

Teamatomic

Like this? But should i put the values in the index? sorry if i dont understand you corectly, this is kinda new for me ;)

<?php
$select_banner = $_POST["select_banner"];
$titletext = $_POST["titletext"];
$titlecolor = $_POST["titlecolor"];
$titlex = $_POST["titlex"];
$titley = $_POST["titley"];
$tagtext = $_POST["tagtext"];
$tagcolor = $_POST["tagcolor"];
$tagx = $_POST["tagx"];
$tagy = $_POST["tagy"];

if ((isset($titletext) || $titletext > "")
      and (isset($tagtext) || $tagtext > "")) {
   $titlecolor = substr($titlecolor, -6);
   $r1 = hexdec(substr($titlecolor, 0, 2));
   $g1 = hexdec(substr($titlecolor, 2, 2));
   $b1 = hexdec(substr($titlecolor, 4, 2));
   $tagcolor = substr($tagcolor, -6);
   $r2 = hexdec(substr($tagcolor, 0, 2));
   $g2 = hexdec(substr($tagcolor, 2, 2));
   $b2 = hexdec(substr($tagcolor, 4, 2));
   $titletext2 = stripslashes($titletext);
   $tagtext2 = stripslashes($tagtext);
   $image = imagecreatefrompng("banner/$select_banner");
   $titlecolor = imagecolorallocate($image, $r1, $g1, $b1);
   $tagcolor = imagecolorallocate($image, $r2, $g2, $b2);
   $font = 'arial.ttf'; <-----
   ImageTTFText($image, $fontSize, $fontRotation, $x_pos, $y_pos, $colorRed, $font, "$windchill_f&#186;F");<----
   ImageString($image, 10, $titlex, $titley, $titletext2, $titlecolor);
   ImageString($image, 10, $tagx, $tagy, $tagtext2, $tagcolor);
   $counterval = 0;
   $filename = "banners/counter.txt";
   $fp = fopen($filename, "r");
   $counterval = fread($fp, 26);
   fclose($fp);
   $counterval = (integer)$counterval + 1;
   $fp = fopen($filename, "w+");
   fwrite($fp, $counterval, 26);
   fclose($fp);
   $newbanner = 'banners/' . $counterval . '.png';
   ImagePNG($image, $newbanner);
   include("header.inc");
   echo "\n";
   echo "<a href=\"$newbanner\"><img src=\"$newbanner\" width=\"468\" height=\"60\" alt=\"Your Generated Banner\" border=\"0\"></a>\n";
   echo "\n\n";
   include("footer.inc");
} 
if ($counterval > 5) {
   $deletebanner = (integer)$counterval - 5;
   $delete = 'banners/' . $deletebanner . '.png';
   unlink("$delete");
} 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.