Page 1 of 1

Layering Images with PHP problem

Posted: Fri May 28, 2010 1:01 pm
by alforddm
I'm working on some code where I layer images using php. The actual code works fine. The problem I'm having is with the images. I started off with a standard image and erased the background using gimp. I then modified the images for use as layers. No problem right? Everything looks great and I save the images as png files for use with php.

The problem surfaces when I use

Code: Select all

$im=imagecreatefrompng("images/bay.png");
header("Content-type: image/png");
imagepng($dest);
imagedestroy($dest);


The images returned have the background back in them. The background does not show anywhere else and view correctly when called with html (even layer correctly).

Does anyone have a clue what is causing this and how to fix it?

Thank you,

Daylene

Re: Layering Images with PHP problem

Posted: Fri May 28, 2010 7:43 pm
by alforddm
I found the problem! Who knew that google would be the solutions? :lol:

luxian.m [at] gmail [dot] com
16-Sep-2008 12:36
Don't forget about imagealphablending() and imagesavealpha() if you're working with [semi]transparent png.

Code: Select all

<?php
$file = 'semitransparent.png'; // path to png image
$img = imagecreatefrompng($file); // open image
imagealphablending($img, true); // setting alpha blending on
imagesavealpha($img, true); // save alphablending setting (important)
?>
edit: Actually I found the solution not the problem I had the problem all along