Closed Thread
Results 1 to 7 of 7

Thread: Adding Custom Text To An Image

  1. #1
    chad's Avatar
    chad is offline Learning Programmer
    Join Date
    Jan 2010
    Location
    Philippines
    Posts
    68
    Rep Power
    0

    Adding Custom Text To An Image

    I have this code to put a text on an image

    Code:
    <?php
    header 
    ("Content-type: image/png");
    $string "test";
    // try changing this as well
    $font 4;
    $width imagefontwidth($font) * strlen($string) ;
    $height imagefontheight($font) ;
    $im imagecreatefrompng("test.png");
    $x imagesx($im) - $width ;
    $y imagesy($im) - $height;
    $backgroundColor imagecolorallocate ($im255255255);
    $textColor imagecolorallocate ($im00,0);
    imagestring ($im$font$x$y$string$textColor);
    imagepng($im);
    ?>
    but it shows me these weird symbols all over the page
    what could be the problem?

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    devnick is offline Newbie
    Join Date
    Feb 2010
    Posts
    2
    Rep Power
    0

    Re: Adding Custom Text To An Image

    Hi,

    The code looks perfect. Usually garbled values are shown if the content type is not right

  4. #3
    chad's Avatar
    chad is offline Learning Programmer
    Join Date
    Jan 2010
    Location
    Philippines
    Posts
    68
    Rep Power
    0

    Re: Adding Custom Text To An Image

    i double checked everything
    the file path, the text, the codes...

    but everytime i test it out
    it shows me all this weird symbols all over the page

  5. #4
    t3tris is offline Newbie
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Re: Adding Custom Text To An Image

    header("content-type: image/png")

  6. #5
    chad's Avatar
    chad is offline Learning Programmer
    Join Date
    Jan 2010
    Location
    Philippines
    Posts
    68
    Rep Power
    0

    Re: Adding Custom Text To An Image

    are you trying to say its case sensitive?

  7. #6
    t3tris is offline Newbie
    Join Date
    Feb 2010
    Posts
    5
    Rep Power
    0

    Re: Adding Custom Text To An Image

    no, no. I messed up. I'm sorry, I didn't see that you had the header already. I just ran it though, and it shows the image on my server. I'm not sure...

  8. #7
    chad's Avatar
    chad is offline Learning Programmer
    Join Date
    Jan 2010
    Location
    Philippines
    Posts
    68
    Rep Power
    0

    Re: Adding Custom Text To An Image

    yeah i got it working already...
    it has messed up with the headers.

    i didnt see there was an include file that has another header content type

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 21
    Last Post: 02-07-2011, 03:18 AM
  2. I need help adding a image
    By CyleDyerHero1 in forum HTML Programming
    Replies: 6
    Last Post: 11-23-2010, 12:09 AM
  3. Adding Background image to JFrame
    By Aaron140 in forum Java Help
    Replies: 4
    Last Post: 11-20-2010, 02:08 AM
  4. Adding Background image
    By pactools in forum C# Programming
    Replies: 1
    Last Post: 04-19-2010, 08:37 PM
  5. adding an image as the background
    By wholikesforms? in forum easyContact
    Replies: 1
    Last Post: 12-06-2007, 05:00 AM

Tags for this Thread

Bookmarks

Posting Permissions

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