Display date within an image?

Discussion in 'Programming' started by Bulldog-Designs, Aug 13, 2009.

  1. #1
    I need an image to automatically update to the current date. I thought maybe using the PHP date function I may be able to update a date in an image.
    is this possible?
     
    Bulldog-Designs, Aug 13, 2009 IP
  2. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #2
    
    <?php 
       header("Content-type: image/jpeg"); 
      //default background image
      $im = @imagecreatefromjpeg("default.jpg")  
      or die("Cannot Initialize new GD image stream"); 
    
      // white background and red text 
      $bg = imagecolorallocate($im, 255, 255, 255); 
      $textcolor = imagecolorallocate($im, 255, 0, 0); 
       
      // write the date at the top left 
      imagestring($im, 5, 0, 0, date('l jS \of F Y h:i:s A'), $textcolor); 
       
      // output the image to the browser
       imagejpeg($im); 
      ImageDestroy ($im); 
    ?>
    
    PHP:
    Course you could also save the image into a local cache of sort.
     
    kblessinggr, Aug 13, 2009 IP