December 8th, 2003, 04:52 PM
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:
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:
<img src="nav_button.php?text=link" />
That way, only the first n bytes specified by the content-length header are downloaded and used, and the image is valid.
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" ] ) );
imagejpeg( $img );
imagedestroy( $img );
$data = ob_get_contents( );
header( "Content-Length: " . strlen( $data ) );
(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!
December 15th, 2003, 04:34 PM
And then I realized that 50free.com's hosting plan is a whole lot better...