Page 1 of 2 12 LastLast
Results 1 to 10 of 19
  1. #1
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default [PHP] How do i... ?

    Hello

    How would I make a script where you would input some text, then that would make images from a font file ??

    Thanks
    Tom
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

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

    Latest Awards:

    Default

    PHP GD

    Couldn't be bothered to write my own code, so yeah here is the PHP.net tutorial with a change to make it save the image.

    Make a file called text.php and inside it put:

    PHP Code:
     <?php
    // Set the content-type
    header("Content-type: image/gif");

    // Create the image
    $im = imagecreatetruecolor(400, 30);

    // Create some colors
    $white = imagecolorallocate($im, 255, 255, 255);
    $grey = imagecolorallocate($im, 128, 128, 128);
    $black = imagecolorallocate($im, 0, 0, 0);
    imagefilledrectangle($im, 0, 0, 399, 29, $white);

    // The text to draw
    $text = $_POST['text'];
    // Replace path by your own font path
    $font = 'font.ttf';

    // Add some shadow to the text
    imagettftext($im, 20, 0, 11, 21, $grey, $font, $text);

    // Add the text
    imagettftext($im, 20, 0, 10, 20, $black, $font, $text);

    $rand = rand(0, 60000);

    // Using imagepng() results in clearer text compared with imagejpeg()
    imagegif($im,'$rand.gif');
    imagedestroy($im);
    ?>
    Make a file called index.php and in it have a form send the data to text.php and name the form which you type the text into called "text".

    Enjoy.
    Last edited by Invent; 30-03-2007 at 08:02 PM.

  3. #3
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    I know but i dunno GD
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

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

    Latest Awards:

    Default

    Look at my post, I editied it ;]

  5. #5
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    That wouldn't let me use a say... .ttf font file?
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

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

    Latest Awards:

    Default

    Yes it would.

    Just upload the font to your site

    And then just change: $font = 'font.ttf';

  7. #7
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    ahh yes didn't see that line

    Thanks Ill see if i can get something going
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  8. #8
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Now... How would I make it so that they could choose a fill and line colour like in Word for this ???
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

  9. #9
    Join Date
    Jun 2005
    Posts
    4,795
    Tokens
    0

    Latest Awards:

    Default

    Quote Originally Posted by Jaffa Cakes! View Post
    Now... How would I make it so that they could choose a fill and line colour like in Word for this ???
    Fill and line are the same thing :S

    To create new colours:

    imagecolorallocate($im, red, green, blue);

    Change the values of red green blue.

  10. #10
    Join Date
    May 2005
    Location
    /etc/passwd
    Posts
    19,110
    Tokens
    1,139

    Latest Awards:

    Default

    Quote Originally Posted by Tomm View Post
    Fill and line are the same thing :S
    No say in like Fireworks, you have line and fill colours for text...
    Quote Originally Posted by Chippiewill View Post
    e-rebel forum moderator
    :8

Page 1 of 2 12 LastLast

Posting Permissions

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