headers and imagecreatefromjpeg

Discussion in 'PHP' started by tikitin, Jul 29, 2007.

  1. #1
    I want to add certain elements dynamically on a picture on a web page.
    Functions like imagecreatefromjpeg, imageellipse, imagecolorallocate and imagejpeg do the trick. but the problem is that they seem to need header("Content-type: image/jpeg").
    Looks like I only can use those functions to make a page containing only a picture. But I want to have both text and pictures on the page! How should I do it? I don't quite grasp that header stuff...
     
    tikitin, Jul 29, 2007 IP
  2. themole

    themole Peon

    Messages:
    82
    Likes Received:
    7
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You'll need to have two separate scripts, one for your text (just like normal) and one for your image. Then you can call your image script on your normal text+php page with the img tag.

    
    <html>
    <body>
    This is my page...
    <img src='image.php' alt='' />
    
    </body>
    </html>
    
    Code (markup):

    You can pass GET variables or set SESSION variables so then the image can generate whatever it is it needs:

    
    <html>
    <body>
    This is my page...
    <?php
    //You could set SESSION vars and then have the image script look at that
    $_SESSION['name'] = 'tikitin';
    $_SESSION['anothervar'] = '1234';
    
    //Or you could just use GET variables
    ?>
    <img src='image.php?name=tikitin&anothervar=1234' alt='' />
    
    </body>
    </html>
    
    Code (markup):

    -the mole
     
    themole, Jul 29, 2007 IP