Need help writing PHP GD Image to file

Discussion in 'PHP' started by Darden12, Oct 25, 2009.

  1. #1
    As a newcomer to php image creating, I have so far succeeded in creating images and sending them to my browser.

    I now would like to create images and output them as files, but I can't yet get that to work. Can someone tell me, for instance, why the following script does not work for me?

    <?php
     
    $degrees="5";
    $offset="0";
    $img=imagecreatefromgif('AutoImages/anime-beach.gif');
    $img=imagerotate($img,$degrees,$offset);
    
     header ("Content-type: image/gif");
    
    
    ImageGIF($img,'test.gif');
     
    imagedestroy($img);
    
    ?>
    PHP:
    Thanks very much in advance for any help.

    Brian
     
    Darden12, Oct 25, 2009 IP
  2. organicCyborg

    organicCyborg Peon

    Messages:
    330
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your code works fine for me, it's just being saved to the file and not being shown in the browser.

    Just add
    
    ImageGIF($img);
    
    Code (markup):
    after or before your first ImageGIF function call.
     
    organicCyborg, Oct 25, 2009 IP
  3. Darden12

    Darden12 Well-Known Member

    Messages:
    107
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    101
    #3
    Thanks very much! It works!

    Brian
     
    Darden12, Oct 25, 2009 IP