PHP Developers Network

drawing on images with php
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

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 ]

<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">


<BODY bgColor=#ffffff vLink=#0000ff>

<DIV align=center>

<h1>EZ Banner Creator</h1>

<TABLE border=1>


   <TD bgColor=#99cc99>

   <FORM action=draw3.php>

   <P align=center>

      <TABLE border=1>


          <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>



          <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 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 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 align=middle colSpan=3><B>Text Line 1:</B><INPUT value="hoodz crew" name=string1 size=43





          <TD align=middle colSpan=3><B>Text Line 2:</B><INPUT value="illest in the game!" name=string2 size=43





          <TD align=middle>

          <INPUT type=submit value="Create Banner">

          <INPUT type=reset value=Reset>





      <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.  






            <P><FONT size=-1>**Color is determined by the RedGreenBlue value.

            To see the values of colors, go <A


            to find your own colors then click your browser's back

            button to return to this page.









<? 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 );


     $counterval = (integer)$counterval + 1;

     $fp = fopen($filename,"w+");

     fwrite($fp, $counterval, 26);

     fclose($fp );

     $newbanner = 'banners/' . $counterval . '.jpg';


     $string1 = '';

     $string2 = '';

     echo '<img src=' . $newbanner . '><br>';

     echo '<a href=' . $newbanner . '>' . $newbanner . '</a>';








^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