Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4

Thread: GD Question

  1. #1
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts

    GD Question

    PHP Code:
    <?php    
    $img_handle 
    ImageCreate (33960) or die ("Cannot Create image");     
    $bg "tc.png";     
    $txt_color ImageColorAllocate ($img_handle231240);     
    ImageString ($img_handle3155,  "Coming Soon...."$txt_color);
    header ("Content-type: image/png");    
    ImagePng ($img_handle);     
    ?>
    My question is. What I am trying to do is I have an image, tc.png, and I want to put text on top of tc.png. It just shows up 339x60 image with a green background. Can someone help?

    Thanks
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!

  • #2
    New Coder
    Join Date
    May 2002
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You will need to allocate at least one more colour. Right now you are creating an image with just one colour, So the background is the only colour it can be the same as the text.

    <?php

    $img_handle = ImageCreate (339, 60) or die ("Cannot Create image");

    $bg = "tc.png";
    $another_color= ImageColorAllocate ($img_handle, 255, 255, 255);
    $txt_color = ImageColorAllocate ($img_handle, 23, 124, 0);

    ImageString ($img_handle, 1, 5, 5, "Coming Soon....", $txt_color);

    header ("Content-type: image/png");

    ImagePng ($img_handle);

    ?>

    That will work.. though I am not sure what font 31 is, 31 does not refer to fontsize but one of the inbuilt fonts which is a number from 1 to 5. For better fonts I recommend true type fonts.

  • #3
    New Coder
    Join Date
    May 2002
    Posts
    58
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Oh I just read the rest of your question. you do not need to create another colour since you are creating an image from an existing png. but you need to use imagecreatefrompng()



    <?php

    $img_handle = imagecreatefrompng("tc.png"); or die ("Cannot Create image");

    $txt_color = ImageColorAllocate ($img_handle, 23, 124, 0);

    ImageString ($img_handle, 1, 5, 5, "Coming Soon....", $txt_color);

    header ("Content-type: image/png");

    ImagePng ($img_handle);

    ?>

    That should work

  • #4
    Regular Coder
    Join Date
    May 2003
    Location
    34 54' N 82 13' W
    Posts
    996
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks
    Stevie Peele
    Neverside IRC Network - irc.veonex.net | tc.tutorialnetwork.org
    #dev - any programming,etc. question
    #design - design discussion and critque
    #central - general chat
    Come join us!


  •  

    Posting Permissions

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