I'm having a problem on a site I made where occasionally, a file I'm overlaying on another file somehow becomes the file saved.
Apparently I can't embed images or post more than two links, which makes it a bit difficult to explain what's going on. I made a demo page on my site with the images and the ImageMagick identify
output. http://blha303.com.au/mcsanta/sodemo.html
And the relevant code:
$skinimage = file_get_contents("https://s3.amazonaws.com/MinecraftSkins/$user.png");
$fp = fopen(realpath(dirname(__FILE__)) ."/tmp/$user.png", "w");
fwrite($fp, $skinimage);
fclose($fp);
$santatemplate = imagecreatefrompng(realpath(dirname(__FILE__)) ."/SantaHatTemplate.png");
imageAlphaBlending($santatemplate, true);
imageSaveAlpha($santatemplate, true);
$userskin = imagecreatefrompng(realpath(dirname(__FILE__)) ."/tmp/$user.png");
imageAlphaBlending($userskin, true);
imageSaveAlpha($userskin, true);
imagecopy($userskin, $santatemplate, 0, 0, 0, 0, imagesx($userskin), imagesy($userskin));
imagepng($userskin, realpath(dirname(__FILE__)) ."/tmp/$user-santa.png");
https://github.com/blha303/mcsanta/blob/master/index.php#L38-L49
This is not an issue with transparency, I think it may be a problem with something about the PNG files, which is why I included the ImageMagick verbose output.
Any suggestions are greatly appreciated :)