combine 2 images into 1

A

Anonymous

Guest
hi,
I can't really help with the code...
but do download the jpgraph.
it really has some cool classess for all that you want, plus the graphs...
AND YES ITS GOT ALPHA BLENDING
 
i'm a newbie, but i've just done that.
<?php // imgCreator.php

header("Content-type: image/jpeg");

$im1 = imagecreatefromjpeg("images/background.jpg");
$im2 = imagecreatefrompng("images/logo.png");
ImageCopy($im1,$im2,0,0,0,0,608,300);look for imageCopy(); in php.net
Imagejpeg($im1,'',90);
imagedestroy($im1);
imagedestroy($im2);
?>

html page
<img src="imgCreator.php" border=0>

waiting for replay
 
You need to enable alpha blending on the base image (this isn't necessary on the one that has transparency for some reason). Modified code would be this:

Code:
<?php // imgCreator.php 
     
header("Content-type: image/jpeg"); 
                                                 
   $im1 = imagecreatefromjpeg("images/background.jpg");
   imagealphablending($im1, true); // this has to be before imagecopy();
   $im2  = imagecreatefrompng("images/logo.png"); 
   imagecopy($im1,$im2,0,0,0,0,608,300);  
   imagejpeg($im1,'',90); 
   imagedestroy($im1); 
   imagedestroy($im2); 
   ?>
 
Back
Top