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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Embed PHP into a image.

    How would i embed PHP into images.

    Examples like this.

    Ive made the image, but i would like to embed some stats into it.

    All help is appreciated. THanks alot!!!

  • #2
    Regular Coder
    Join Date
    Sep 2005
    Posts
    394
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Firstly, you embed images into php not visa versa. You must pass headers to the browser, telling it that the php page is an image e.g.

    PHP Code:
    Header ("Content-type: image/jpeg"); 
    You can then use the ImageString function (look on php.net) to write text over an image.

    ~Phil~

  • #3
    New to the CF scene
    Join Date
    Jun 2006
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts
    o ok thanks alot.


    ill look it up.

    can i use this?

    Code:
    Code:
     <?php
    // create a 100*30 image
    $im = imagecreate(100, 30);
    
    // white background and blue text
    $bg = imagecolorallocate($im, 255, 255, 255);
    $textcolor = imagecolorallocate($im, 0, 0, 255);
    
    // write the string at the top left
    imagestring($im, 5, 0, 0, "Hello world!", $textcolor);
    
    // output the image
    header("Content-type: image/jpeg");
    imagejpeg($im);
    ?>

  • #4
    New Coder
    Join Date
    Jun 2006
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts
    HI
    I dont know to work with gd but your code seems to work...

  • #5
    New to the CF scene
    Join Date
    Jul 2006
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I was wondering if it is possible to embed a link into this image. I read about it somewhere with gd lib but cant seem to find it?

    Basically i want to share this dynamic image but have link back to my site built into it.

    Any Ideas?

    Mike


  •  

    Posting Permissions

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