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 3 of 3
  1. #1
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default How to use PHP GD to write text

    This is a small code which explains how to use PHP GD to produce an image with text from a font on a website.

    PHP Code:
     <?php
    header
    ("Content-type: image/gif"); // We have to set the header of the file as its an image

    $text = @$_GET['text']; // Get the text to write
    // The $_GET function grabs the data specified by the ?text parameter on the URL

    $font 'Volter.ttf'// Set the TTF font we want to use
    // This is just a variable set, which we will later use in the imagettftext funciton

    $fontsize "6.5"// Set the size of the font we want to use
    // This again is just a variable like above.



    // Create the image
    $size imagettfbbox($fontsize0$font$text); // Set the positions of the area of the font
    $width $size[2] + $size[0] + 8;
    $height abs($size[1]) + abs($size[7]); // Get values
    // We have the right sizes for the text

    $im imagecreate($width$height);
    // Create the image of the right size for the text to fit

    // Create some colors
    $white imagecolorallocate($im255255255); // Create the colour white using RGB
    $black imagecolorallocate($im000); // Create the colour black using RGB


    # The imagecolorallocate uses RGB colours to allocate an individual colour to a string. EG/ $white.

    // Make a colour transparent
    $colourBlack imagecolorallocate($im255255255); // Set colour black using RBG
    imagecolortransparent($im$colourBlack); // Make colour black transparent

    # imagecolortransparent makes the pre-made string which has been allocated a colour transparent on the image.

    // Add the text
    imagefttext($im$fontsize00abs($size[5]), $black$font$text);

    # imagettftext writes the text to the image, the different stages of the funciton are explain below the php code (from php.net)

    imagegif($im); // Output the image using imagegif()
    imagedestroy($im); // Delete the image to keep server load down
    ?>

  2. #2
    Join Date
    May 2007
    Posts
    8
    Tokens
    0

    Default

    Hmm.. Thats is funny

    Really simple to edit with the official habbo letters
    Thnx
    Last edited by menno; 19-05-2007 at 09:42 PM. Reason: i made it in dutch :P
    Habbo.nl , i am dutch :eusa_danc
    Sorry for my bad english :eusa_shhh

    hoi

  3. #3
    Join Date
    May 2005
    Location
    San Francisco, CA
    Posts
    7,160
    Tokens
    2,331

    Latest Awards:

    Default

    English please =D

Posting Permissions

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