Maracles Posted July 22, 2009 Share Posted July 22, 2009 Hi, I am trying to use the imagecreatefrompng() function to overlay a logo image onto a background image and I have got it working as a standalone .php file. The code is below: <?php header("Content-type:image/png"); function overlayPNG($imgname) { $mark = imagecreatefrompng("white.png"); list($mwidth, $mheight) = getimagesize("white.png"); $img = imagecreatefrompng($imgname); list($iwidth, $iheight) = getimagesize($imgname); imagecopy($img, $mark, $iwidth-$mwidth-50, $iheight-$mheight-5, 0, 0, $mwidth, $mheight); imagejpeg($img); } overlayPNG('kingkong.png'); ?> The problem is as soon as I try to incorporate this into my actual website via an Include() in my header.php file the code breaks. All the header code is: <div id="header"> <?php include('example.php'); ?> </div> It does not work even if I add the code directly. The error I get is a broken file logo in the top left of my page. It even prevents the rest of my code from running. This is the first time I have used this function, can anyone offer some help? Link to comment https://forums.phpfreaks.com/topic/167031-solved-imagecreatefrompng-issue/ Share on other sites More sharing options...
thebadbad Posted July 22, 2009 Share Posted July 22, 2009 You will need to call the script as the source of an image, in your HTML: <div id="header"><img src="example.php" alt="" /></div> Link to comment https://forums.phpfreaks.com/topic/167031-solved-imagecreatefrompng-issue/#findComment-880671 Share on other sites More sharing options...
Maracles Posted July 22, 2009 Author Share Posted July 22, 2009 Legend. Thanks very much that has worked. Link to comment https://forums.phpfreaks.com/topic/167031-solved-imagecreatefrompng-issue/#findComment-880678 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.