• home
  • forum
  • my
  • kt
  • download
  • PHP Text Images

    Author: 2007-08-11 17:54:10 From:

    In this tutorial I will be teaching you to make a really basic text on plain/no background system. I'll be using the GD library so check you have that installed ;).

    Simple enough idea, you  can allow users to edit the text appearing on the image with GET details. The idea is that you can adapt this simple script into your own site. It's been coded for Bozebo so he can use it to put emails in profiles into images and stop bots from grabbing. It can be adapted to take data from a database and display it, you could even make an image verification system with it!

    I'm not going to go through it line by line, instead I'll just annotate it as I go. Enjoy...

    PLAIN TEXT

    PHP:

    1. <?
    2.  
    3. header("Content-type: image/png"); // Tell  the browser it's an image, not a .php file.
    4.  
    5. $text = stripslashes($_GET['text']); // Take the text and stop it from messing up with '
    6.  
    7. $number = strlen($text);  // Count the chars in the text.
    8.  
    9. $number = ($number*7)+9; // Times this by 7 and add 9 to make it look the right size.
    10.  
    11. $im = imagecreate($number, 24); // Create the basic size, $number x 24
    12.  
    13. $colour1 = imagecolorallocate($im, 0, 0, 0); // Background (RGB) black.
    14.  
    15. $colour2 = imagecolorallocate($im, 255, 255, 255); // Background white.
    16.  
    17. imagestring($im, 3, 5, 5$text, $colour2); // Add the text to the image.
    18.  
    19. imagepng($im); // Create and display the image.
    20.  
    21. imagedestroy($im); // Cast the image from the server (will cause lag eventually if you don't).
    22.  
    23. ?>

    discuss this topic to forum

    relation tutorial

    No relevant information

    Category

      Ad Management (4)
      Calendars (3)
      Chat Systems (7)
      Content Management (6)
      Cookies and Sessions (8)
      Counters (8)
      Database Related (8)
      Date and Time (9)
      Development (6)
      Discussion Boards (7)
      E Commerce (6)
      Email Systems (9)
      Error Handling (5)
      File Manipulation (10)
      Flash and PHP (4)
      Form Processing (7)
      Guestbooks (8)
      Image Manipulation (3)
      Installing PHP (5)
      Introduction to PHP (9)
      Link Indexing (6)
      Mailing List Management (8)
      Miscellaneous (10)
      Networking (6)
      News Publishing (6)
      OOP (8)
      PEAR (6)
      PHP vs Other Languages (2)
      Polls and Voting (5)
      Postcards (0)
      Randomizing (8)
      Redirection (8)
      Searching (6)
      Security (6)
      Site Navigation (7)
      User Authentication (10)
      WAP and WML (7)
      Web Fetching (0)
      Web Traffic Analysis (11)
      XML and PHP (0)

    New

    Hot