PHP Developers Network
http://forums.devnetwork.net/

drawing on images with php
http://forums.devnetwork.net/viewtopic.php?f=32&t=23372
Page 1 of 1

Author:  rapaddict_dot_com [ Fri Jul 02, 2004 2:40 am ]
Post subject:  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?

Author:  rapaddict_dot_com [ Fri Jul 02, 2004 2:44 am ]
Post subject: 

also i want it to save as $sess_user."_banner.jpeg"

and if that file already exists then I want it to delete it

does anyone know how to do all this?

Author:  feyd [ Fri Jul 02, 2004 2:46 am ]
Post subject: 

read the [php_man]image[/php_man] function documentation.

Author:  rapaddict_dot_com [ Fri Jul 02, 2004 3:23 am ]
Post subject: 

Syntax: [ Download ] [ Hide ]
<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
Syntax: [ Download ] [ Hide ]
tags when posting code. Read:  </span>

Author:  feyd [ Fri Jul 02, 2004 3:32 am ]
Post subject: 

Well.. it looks like the RGB values are already 0-255 fields... Next thing, that script was written with register_globals on.. for fonts, you'll have to enumerate the fonts you have available for them to use.

Author:  rapaddict_dot_com [ Sat Jul 03, 2004 12:20 am ]
Post subject: 


Author:  feyd [ Sat Jul 03, 2004 12:25 am ]
Post subject: 


Author:  m3mn0n [ Sat Jul 03, 2004 12:30 am ]
Post subject: 


Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group
http://www.phpbb.com/