SitePoint Sponsor

User Tag List

Results 1 to 15 of 15
  1. #1
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Having Text Or A Pic Appear In A Specified Area At A Certain Date

    I already made this post in the PHP forum, but I don't think it belongs there.

    I need help, and in a major way. I'm making a signature for my favorite football team. After a certain date, say the day after the game, I want text or an image of text I do to pop up in a specified area in the signature.

    So I guess the major problems are:

    -How do I designate a specific area? Cut it up in Photoshop?

    -How do I make the text or text pic show up at a certain date?

    I want to make a note that I want the text or text pic to stay there until the next specified day comes up.

  2. #2
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a pic to help:
    Attached Images Attached Images

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If it wasn't for the fact that you'd need the text placed on an image, you could simple use Javascript, though to put text over an image you can use the GD extension easily for this

    Afraid though that I've not really used GD much as I have no real need to, but you might consult the online manual for this.

    Also, have a look at www.hotscripts.com as there is certainly something there you'll find to help you.

  4. #4
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Widow Maker
    If it wasn't for the fact that you'd need the text placed on an image, you could simple use Javascript, though to put text over an image you can use the GD extension easily for this

    Afraid though that I've not really used GD much as I have no real need to, but you might consult the online manual for this.

    Also, have a look at www.hotscripts.com as there is certainly something there you'll find to help you.
    I don't know PHP too well, but I do know HTML extremely good. What do you mean GD extension?

  5. #5
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    If it's for a forum signature then you'd need to use the GD library but if it's like a banner on your site or something then you can just use CSS to achieve that.

    You'd need to write a PHP script to check the date, compare it with dates already specified by you and then build and output the image. I'd probably be easier to use a database for this but you could use text files if necessary.
    Edit:


    The GD extension is a PHP extension that allows you to create and edit images.

  6. #6
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's going to be a signatue for a forum.

    If you guys can help me out making this happen, I'd really appreciate it!

  7. #7
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Saved you the bother of doing a search on hot scripts as I suggested, and found this which will help you do what you want

    http://www.hotscripts.com/Detailed/19862.html

    Not looked at the details, nor the script but do note that as far as using PHP with GD there is an issue for which version of GD you have on your host.

    You have version 1.x (usually 1.8) or version 2.x.

    Version 2.x is the only version, that I'm aware of that is, to support PNG formats. The differences between the versions is function calls from PHP, again, read the online documentation for more information, something I'm afraid I can't do for you

    Good luck btw.

  8. #8
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK so what do I do after I get the script, which seems to be taking forever to get my validation e-mail

  9. #9
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK I managed to download it and the example, but I'm clueless as what to do now.
    Last edited by Rookie13; Sep 4, 2004 at 20:33.

  10. #10
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Copy and Paste the script to this thread, remember to read this first,

    http://www.sitepoint.com/forums/misc.php?do=bbcode

    On how to post script to this forum. Look two thirds way down the page for 'PHP Code' and learn to use these tags.

    Failure to do so will result in my annoyance, and without a doubt, my lack of help to you

  11. #11
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well,there was two, the example and the actual PHP file that came in the zip file, I will paste both.

    Example
    PHP Code:
    <?
        
    /*
            Pull in all the requirements
        */
        
    require_once("class.img_add_txt.php");

        
        
    /*
            coupon image
        */
        
    $config=array(
                    
    "text" => "Test",
                    
    "text_colors" => "0 0 0"// RGB Seperated by spaces
                    
    "image_loc" => "/sigs/hurricanes.jpg",
                    
    "image_type" => "JPEG"// PNG and GIF Supported
                    // Optional arguments; default is center area on image
                    
    "x_pos" => "0",
                    
    "y_pos" => "0",
                    
        );
        
        
    $graphic=new img_add_txt($config);
    ?>
    Actual PHP File That Also Came With the Example:
    PHP Code:
    <?
        
    class img_add_txt{
        
        
            
    /*
                Created by Richard Sumilang
                [url]http://www.richard-sumilang.com[/url]
                
                
                object img_add_txt($array);
                ------------------------------------
                This function adds text on top of an image
                
                Usage:
                ------------------------------------
                $config=array(
                            "text" => "Coupon: Here is your free coupon",
                            "text_colors" => "255 68 0", // RGB Seperated by spaces
                            "image_loc" => "example.jpg",
                            "image_type" => "JPEG", // PNG and GIF Supported
                            // Optional arguments; default is center area on image
                            "x_pos" => "",
                            "y_pos" => "",
                            
                );
                
                $graphic=new img_add_txt($config);
            */
            
            
    function img_add_txt($config){
        
                
    // header
                //header("Content-Type: image/gif");
                
    $this->func_header($config['image_type']);
                
                
    // set up image
                
    $im ImageCreateFromJPEG($config['image_loc']);
                
                
    // Set up text colors
                
    $text_colors=explode(" "$config['text_colors']);
                
    $text_color ImageColorAllocate($im$text_colors['0'], $text_colors['1'], $text_colors['2']);
                
                
    // get font dimensiona
                
    $font_height ImageFontHeight(3);
                
    $font_width ImageFontWidth(3);
                
                
    // get image dimensiona
                
    $image_height ImageSY($im);
                
    $image_width ImageSX($im);
                
                
    // get string length
                
    $length $font_width strlen($config['text']);
                
                
    // set the x, y cords of where the text will be placed
                
    if(empty($config['x_pos'])){
                    
    // calculate start coordinates for string
                    
    $image_center_x = ($image_width/2)-($length/2);
                }else{
                    
    $image_center_x $config['x_pos'];
                }
                if(empty(
    $config['y_pos'])){
                    
    // calculate start coordinates for string
                    
    $image_center_y = ($image_height/2)-($font_height/2);
                }else{
                    
    $image_center_y $config['y_pos'];
                }
                
                
    // write string
                
    ImageString($im3$image_center_x$image_center_y$config['text'], $text_color);
                
                
    // output to browser
                
    $this->output_image($config['image_type'], $im);
            
            }
    // End img_add_txt
            
            
            /*
                Output the correct header based
                on file type
            */
            
    function func_header($var){
                
                switch(
    $var){
                    case 
    "PNG":
                        
    header("Content-Type: image/png");
                    break;
                    
                    case 
    "GIF":
                        
    header("Content-Type: image/gif");
                    break;
                    
                    case 
    "JPEG":
                        
    header("Content-Type: image/jpeg");
                    break;
                }
                
            }
    // End func_header
        
        
            /*
                Output the correct image type
                based on type
            */
            
    function output_image($var$pointer){
                
                switch(
    $var){
                    case 
    "PNG":
                        
    ImagePNG($pointer);
                    break;
                    
                    case 
    "GIF":
                        
    ImageGIF($pointer);
                    break;
                    
                    case 
    "JPEG":
                        
    ImageJPEG($pointer);
                    break;
                }
                
            } 
    // End out output image
                
        
    // End of class
    ?>
    Attached Files Attached Files

  12. #12
    Non-Member
    Join Date
    Jan 2004
    Location
    Planet Earth
    Posts
    1,764
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry, but going by the example, it should be pretty clear how to use it, surely ?

    I've just looked over the entire class, and it does the whole job for you.

    To put an end to your misery, this is my amended script of the example,

    PHP Code:
    $config=array( 
                    
    "text" => "YOUR TEXT GOES HERE"
                    
    "text_colors" => "0 0 0"// RGB Seperated by spaces 
                    
    "image_loc" => "/sigs/hurricanes.jpg"
                    
    "image_type" => "JPEG"// PNG and GIF Supported 
                    // Optional arguments; default is center area on image 
                    
    "x_pos" => "0"
                    
    "y_pos" => "0"
                     
        ); 
         
        
    $graphic=new img_add_txt($config); 
    Where it says 'YOUR TEXT GOES HERE', is where you place the text you want over the image, and that is it.

    The script even takes care of headers for you, to to put it the image in your HTML page, you'd have something like this, yes ?

    Code:
    ...
    <img src="image.php' border="0" />
    ...
    The SRC is what you name the PHP file, ie I've named it image.php. That is all you'd need to do

    Some advice though, and me being a polite person as well, is to learn PHP for yourself

  13. #13
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    OK, but now I need to use this in a signature for a forum. Also, how do I set up the GD library or whatever, and set it up so it changes the games being shown on the specific date. This has completely lost me, considering I only know the very basics of PHP. Any help is MUCH MUCH MUCH appreciated! And thanks for everything you've done so far, I REALLY appreciate it!

    Keep in mind, this signature will be for forums.

    Here's what I've got so far:

    PHP Code:
    <?
        
    /*
            Pull in all the requirements
        */
        
    require_once("class.img_add_txt.php");

        
        
    /*
            coupon image
        */
        
    $config=array(
                    
    "text" => "YOUR TEST GOES HERE",
                    
    "text_colors" => "255 255 255"// RGB Seperated by spaces
                    
    "image_loc" => "hurricanes.jpg",
                    
    "image_type" => "JPEG"// PNG and GIF Supported
                    // Optional arguments; default is center area on image
                    
    "x_pos" => "0",
                    
    "y_pos" => "0",
                    
        );
        
        
    $graphic=new img_add_txt($config);
    ?>
    HTML Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Untitled Document</title>
    </head>
    
    <body>
    <img src="example.php" border="0" />
    </body>
    </html>
    http://www.teampeerless.com/sigs/hurricanes.htm

  14. #14
    ********* Wizard silver trophy Cam's Avatar
    Join Date
    Aug 2002
    Location
    Burpengary, Australia
    Posts
    4,495
    Mentioned
    0 Post(s)
    Tagged
    1 Thread(s)
    Well if you browse to example.php then you'll see that the path in your include is wrong.

  15. #15
    SitePoint Zealot
    Join Date
    May 2004
    Location
    Avon
    Posts
    111
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What do you mean?


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •