jonniejoejonson Posted November 4, 2009 Share Posted November 4, 2009 The following code uses the gd library to draw a blue sqaure... $width = 50; $height = 50; $image = ImageCreate($width, $height); $blue = ImageColorAllocate($image, 56, 102, 211); ImageFill($image, 0, 0, $blue); ImageJpeg($image); This works fine until you try and print anything before or after the image... for example if you add the print 'hello world' before the ImageJpeg function it breaks... I want to know how you can create agd image and output it with other things like text! regadrs J for example if Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/ Share on other sites More sharing options...
GingerRobot Posted November 4, 2009 Share Posted November 4, 2009 What do you mean by breaks? What actually happens? Also, you should be setting the content type with the header function if you're outputting to a browser. Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/#findComment-950948 Share on other sites More sharing options...
PFMaBiSmAd Posted November 4, 2009 Share Posted November 4, 2009 Every image on a web page requires an <img tag - http://w3schools.com/html/html_images.asp The URL that you put into the src="..." attribute must be to a .php script that outputs the correct content-type header followed by the image data (your GD code you posted.) Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/#findComment-950950 Share on other sites More sharing options...
jonniejoejonson Posted November 4, 2009 Author Share Posted November 4, 2009 I want to be able to output both text and an image that i create using the gd library. eg: $image = ImageCreate(50,50); $blue = ImageColorAllocate($image, 56, 102, 211); ImageFill($image, 0, 0, $blue); header('Content-type: image/jpeg'); ImageJpeg($image); How can i add some text to output before the image is displayed... regards J Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/#findComment-950954 Share on other sites More sharing options...
jonniejoejonson Posted November 4, 2009 Author Share Posted November 4, 2009 okay thanks PFMaBiSmAd i will look into that now... i think that is what iwasn't getting, Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/#findComment-950955 Share on other sites More sharing options...
jonniejoejonson Posted November 4, 2009 Author Share Posted November 4, 2009 Thanks PFMaBiSmAd that was exactly what the problem was... cheer J Quote Link to comment https://forums.phpfreaks.com/topic/180267-solved-gd-library-draw-image-print-stuff-before-or-after/#findComment-950962 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.