Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 2 of 2

Thread: The GD Function

  1. #1
    Join Date
    Oct 2006
    Location
    Northampton
    Posts
    694
    Tokens
    142

    Default The GD Function

    I'm not a beginner as such to the language of PHP, however the GD function is puzzling me... I would appreciate a script (with comments if possible) which merged with a HTML based form, would allow me to generate a text based image.

    All attempts, working or otherwise, will be appreciated and reputation will be awarded to such users.

    Thank you, James.
    Last edited by JamesRouale; 11-12-2006 at 12:05 AM.
    Good-bye signature, I love <NOT ALLOWED NAME AT ALL> despite the infraction his last name got me.

    Free speech? Not anymore, you gotta' love this forum.

  2. #2
    Join Date
    Aug 2004
    Location
    bristol
    Posts
    3,799
    Tokens
    0

    Latest Awards:

    Default

    PHP Code:
    <?php

      header
    ('content-type: image/png');
      
    $m = ($_GET['m']) ? $_GET['m'] : 'No Message';

      
    $image imagecreate(25025);
      
    $black imagecolorallocate($image255255255);
      
    $white imagecolorallocate($image000);
      
    imagestring($image11010$m$white);
      
    imagepng($image);
      
    imagedestroy($image);

    ?>
    You can change GET to POST, and on your basic form have a field named "m", where the user enters their message. Alternatively, you could use JavaScript to make your page display the image more dynamically:

    HTML Code:
    <html>
    <head>
      <title>GD Example</title>
      <script type="text/javascript">
      <!--
      function li() {
        var m = document.getElementById('message');
        var i = document.getElementById('image');
        i.src = 'image.php?m='+m.value;
        m.value = '';
        m.select();
      }
      -->
      </script>
    </head>
    <body>
    <pre>
      <input id="message" /> <button onclick="li();">Display</button>
      <img src="image.php" id="image" />
    </pre>
    </body>
    </html>
    kinda quit.

Posting Permissions

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