Hello Guys,
I stumbled on a problem with the implementation of imagecreate() and imagecopy().
Basically, what I'm trying to achieve is to merge 2 image... pretty straight forward, huh.
image 1 = image generated using imagecreate()
image 2 = pre-made image that's on our webserver - transparent / .png format
The problem is this... the image I created using imagecreate() and save it as imagepng() -- works fine until to the point of the implementation of imagecopy()... the overlap / pre-made image does have a background color instead of a transparent results.
But using the image created using photoshop as base image / image 1 and save it as .png format or transparent works great and produce the results that I wanted.
Here's the actual codes that I have.
<?php // create image $image = imagecreate(336, 280); $backgroundImage = imagecolorallocate($image, 0xff, 0x00, 0x00); // put background red imagecolortransparent($image); $filename = md5(strftime('%Y-%m-%d %T')); imagepng($image, 'downloads/'. $filename .'.png'); imagedestroy($image); // use the created image $background = imagecreatefrompng('downloads/'. $filename .'.png'); // background image... get the saved image $overlap = imagecreatefrompng('tmpl/images/eco_car.png'); // overlap - 296x133 //imagealphablending($overlap, true); //imagesavealpha($overlap, true); imagealphablending($background, false); imagesavealpha($background, true); imagecopy($background, $overlap, 0, 10, 0, 0, 296, 133); header('Content-Type: image/png'); imagepng($background); imagedestroy($background); imagedestroy($overlap); ?>
I'm already out of ideas in this problem.
thanks in advance and more power to this forum site.