Jump to content

[SOLVED] imagecreatefrompng() issue


Maracles

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.