Results:  

Voters
0 You may not vote on this poll

  • 0%
    #1
  1. No Profile Picture
    Brony & F/OSS Advocate
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2003
    Location
    Anaheim, CA (USA)
    Posts
    6,655
    Rep Power
    2476

    Post PLEASE READ: Lycos UK & GD Library: How to make them work


    EDIT: Sorry, the second poll option is supposed to say "I use either of them very little or none at all."

    For a few months, since I had signed up for Lycos UK hosting, I liked the idea that they had they GD library available for dynamic images. So I tried to make a dynamic navigation image that could be called like so:
    Code:
    <img src="nav_button.php?text=link" />
    with no luck. When I saved the image's binary file to my HDD and opened it in notepad, I noticed their ad-script at the end, which make the image invalid. After several hours or cursing at Lycos, I figured it all out. you need a Content-Length header for everything that is not HTML. So my code came down to this:
    PHP Code:
    <?php
      
    //File: nav_button.php
      
    header"Content-Type: image/jpeg" );
      
    $img imagecreatefromjpeg"nav_blank.jpg" );
      
    $color imagecolorallocate$img,$RR$GG$BB );
      
    imagettftext$img$size$angle$x$y$color"/path/to/font.ttf"urldecode$_GET"text" ] ) );
      
    ob_start( );
      
    imagejpeg$img );
      
    imagedestroy$img );
      
    $data ob_get_contents( );
      
    ob_end_clean( );
      
    header"Content-Length: " strlen$data ) );
      echo 
    $data;
      exit;
    ?>
    That way, only the first n bytes specified by the content-length header are downloaded and used, and the image is valid.
    (It seems to work for me, anyways...)

    EDIT: And as I soon figured out, putting a content-length header will almost always fix probelms with images and binary streams.

    I hope this helps someone!
    ~~ Peter ~~ :: ( Who am I? ) :: ( Peter's Musings: Uploading myself, bit by bit... ) :: ( Electronic Frontier Foundation ) :: ( I'm a GNU/Linux addict and Free Software Advocate. ) :: ( How to Ask Questions the Smart Way ) :: ( The Fedora Project, sponsored by Red Hat ) :: ( GNOME: The Free Software Desktop Project ) :: ( GnuPG Public Key ) :: ( About me on the WIki )
  2. #2
  3. No Profile Picture
    Brony & F/OSS Advocate
    Devshed Supreme Being (6500+ posts)

    Join Date
    Jul 2003
    Location
    Anaheim, CA (USA)
    Posts
    6,655
    Rep Power
    2476
    And then I realized that 50free.com's hosting plan is a whole lot better...

IMN logo majestic logo threadwatch logo seochat tools logo