drawing on images with php
Moderator: General Moderators
-
- Forum Commoner
- Posts: 27
- Joined: Tue Mar 16, 2004 4:54 pm
drawing on images with php
I have a site where I want people to be able to make personal banners for there homepage
I want it to have 2 variables for the text
$text-name
and $text-desc
so it has the pre-selected banner and it adds text-name in big letters with customizable colors/fonts and the desc smaller
is there a way to do this?
I want it to have 2 variables for the text
$text-name
and $text-desc
so it has the pre-selected banner and it adds text-name in big letters with customizable colors/fonts and the desc smaller
is there a way to do this?
-
- Forum Commoner
- Posts: 27
- Joined: Tue Mar 16, 2004 4:54 pm
-
- Forum Commoner
- Posts: 27
- Joined: Tue Mar 16, 2004 4:54 pm
Code: Select all
<HTML><HEAD>
<TITLE>EZ Banner -- Online Banner Creator</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="keywords" PHP, Cynthia Porter, Banner Generator">
<meta name="description" content="PHP Program to generate banners on-line.">
<meta name="author" content="Cynthia Porter">
</HEAD>
<BODY bgColor=#ffffff vLink=#0000ff>
<DIV align=center>
<h1>EZ Banner Creator</h1>
<TABLE border=1>
<TR>
<TD bgColor=#99cc99>
<FORM action=draw3.php>
<P align=center>
<TABLE border=1>
<TR>
<TD align=left><b>Banner Color</b></td>
<TD align=middle><B>Line 1 Text Color</B></TD>
<TD align=right><B>Line 2 Text Color</B></TD>
</TR>
<TR>
<TD align=left>
<B>R</B><INPUT name=r_b size=3 value=255 maxsize="3">
<B>G</B><INPUT name=g_b size=3 value=000 maxsize="3">
<B>B</B><INPUT name=b_b size=3 value=000 maxsize="3">
</TD>
<TD align=middle>
<B>R</B><INPUT name=r_t1 size=3 value=000 maxsize="3">
<B>G</B><INPUT name=g_t1 size=3 value=000 maxsize="3">
<B>B</B><INPUT name=b_t1 size=3 value=000 maxsize="3">
</TD>
<TD align=right>
<B>R</B><INPUT name=r_t2 size=3 value=255 maxsize="3">
<B>G</B><INPUT name=g_t2 size=3 value=255 maxsize="3">
<B>B</B><INPUT name=b_t2 size=3 value=255 maxsize="3">
</TD>
</TR>
<TR>
<TD align=middle colSpan=3><B>Text Line 1:</B><INPUT value="hoodz crew" name=string1 size=43
maxsize="80">
</td>
</tr>
<tr>
<TD align=middle colSpan=3><B>Text Line 2:</B><INPUT value="illest in the game!" name=string2 size=43
maxsize="80">
</td>
</tr>
<TR>
<TD align=middle>
<INPUT type=submit value="Create Banner">
<INPUT type=reset value=Reset>
</td></tr>
</TABLE>
<p><b>Instructions:</B><br>
<P>Choose your Background, Text Line 1, and Text Line 2 colors.
Enter Text Line 1 and Text Line 2 as this will be the text that
will be on your banner. <br>
Click the "Create Banner" button and your banner will appear at the
bottom of this page along with its URL.
<br><br>
<TABLE>
<TR>
<TD>
<P><FONT size=-1>**Color is determined by the RedGreenBlue value.
To see the values of colors, go <A
href="http://www.websitetips.com/designer/colors2.html">here</A>
to find your own colors then click your browser's back
button to return to this page.
</FONT></P></TD></TR></TABLE>
</FORM>
<br>
</td></tr></table>
</DIV>
<center>
<br><br><br>
<? if ((isset($string1) || $string1 > "")
and (isset($string2) || $string2 > "")) {
chmod("banners", 0777);
$id = imagecreatefromjpeg("banners/1.jpg");
//$id = ImageCreate(460, 40);
//ImageFilledRectangle ($id, 0, 0, 460, 40, $bgc);
$bgc = ImageColorAllocate($id, $r_b, $g_b, $b_b);
$color1 = ImageColorAllocate($id, $r_t1, $g_t1, $b_t1);
$color2 = ImageColorAllocate($id, $r_t2, $g_t2, $b_t2);
ImageString($id, 5, 10, 2, $string1, $color1);
ImageString($id, 5, 10, 20, $string2, $color2);
$counterval = 0;
$filename = "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 . '.jpg';
ImagePNG($id,$newbanner);
$string1 = '';
$string2 = '';
echo '<img src=' . $newbanner . '><br>';
echo '<a href=http://ezbanner.sourceforge.net/' . $newbanner . '>http://ezbanner.sourceforge.net/' . $newbanner . '</a>';
}
?>
</center>
<center>
<br><br>
</center>
</BODY></HTML>
^I got that code from a website.
How do I make it so the person can edit which font is being used? and so the colors on the form are RED GREEN BLUE instead of the hex codes.
feyd | Please use
Code: Select all
tags when posting code. Read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]
-
- Forum Commoner
- Posts: 27
- Joined: Tue Mar 16, 2004 4:54 pm
RED in a form's drop down menu can be: 255-0-0
GREEN in a form's drop down menu can be: 0-255-0
BLUE in a form's drop down menu can be: 0-0-255
eg.
Then on the form handling page, [php_man]explode[/php_man]() by "-" and you have an array of the hex values.
eg.
GREEN in a form's drop down menu can be: 0-255-0
BLUE in a form's drop down menu can be: 0-0-255
eg.
Code: Select all
<option value="255-0-0">Red Font</option>
eg.
Code: Select all
<?php
$hex = explode ("-", $color);
?>