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 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. 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.) 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 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, 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 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
Archived
This topic is now archived and is closed to further replies.