toolman Posted January 15, 2010 Share Posted January 15, 2010 Hi there, I am trying to insert two php created image on one page, but I cannot get the second to appear. This is my code: index.php: <?php header("Content-type: image/png"); //prints the image header ?> <?php include("head.php"); ?> <?php include("body.php"); ?> <?php echo"<img src='head.php' />"; ?> <?php echo"<img src='body.php' />"; ?> head.php: <?php $head = isset($_GET['text']) ? $_GET['text'] : "this is the head"; //gets the text from the URL, I modified this to not throw errors $im = imagecreatefrompng("images/head_image.png"); //Makes an image object $orange = imagecolorallocate($im, 220, 210, 60); //creates a reference to the color orange $px = (imagesx($im) - 7.5 * strlen($head)) / 2; imagestring($im, 3, $px, 9, $head, $orange); //writes the texst "string" in orange on the image imagepng($im); //outputs the image as binary data imagedestroy($im); //destroys the memory for the resource of the image ?> body.php: <?php $body = isset($_GET['text_body']) ? $_GET['text_body'] : "this is the body"; //gets the text from the URL, I modified this to not throw errors $im_body = imagecreatefrompng("images/body_image.png"); //Makes an image object $orange_body = imagecolorallocate($im_body, 220, 210, 60); //creates a reference to the color orange $px_body = (imagesx($im_body) - 7.5 * strlen($body)) / 2; imagestring($im_body, 3, $px_body, 9, $body, $orange_body); //writes the texst "string" in orange on the image imagepng($im_body); //outputs the image as binary data imagedestroy($im_body); //destroys the memory for the resource of the image ?> Any ideas what is wrong? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/ Share on other sites More sharing options...
Felex Posted January 15, 2010 Share Posted January 15, 2010 hmm try reordering ? <?php include("head.php"); ?> <?php echo"<img src='head.php' />"; ?> <?php include("body.php"); ?> <?php echo"<img src='body.php' />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/#findComment-995879 Share on other sites More sharing options...
toolman Posted January 15, 2010 Author Share Posted January 15, 2010 Thanks I tried thanks, but still only the head.php image is showing. Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/#findComment-995882 Share on other sites More sharing options...
toolman Posted January 21, 2010 Author Share Posted January 21, 2010 Hi I have tried this, but it still doesn't work. <?php header("Content-type: image/png"); //prints the image header ?> <?php include("head.php"); ?> <?php echo"<img src='head.php' />"; ?> <?php include("body.php"); ?> <?php echo"<img src='body.php' />"; ?> Any ideas? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/#findComment-999502 Share on other sites More sharing options...
wildteen88 Posted January 21, 2010 Share Posted January 21, 2010 Hi I have tried this, but it still doesn't work. <?php header("Content-type: image/png"); //prints the image header ?> <?php include("head.php"); ?> <?php echo"<img src='head.php' />"; ?> <?php include("body.php"); ?> <?php echo"<img src='body.php' />"; ?> Any ideas? Thanks You need to be setting the content type header("Content-type: image/png"); On the first line of head.php and body.php You'd display your images like so <?php echo"<img src='head.php' /> <br /> <img src='body.php' />"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/#findComment-999505 Share on other sites More sharing options...
toolman Posted January 21, 2010 Author Share Posted January 21, 2010 Thanks very much it worked Quote Link to comment https://forums.phpfreaks.com/topic/188636-php-gd-help/#findComment-999509 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.