Join Multiple transparent png image in Single image into php -
friends want generate 1 png image multiple transparent png image issue can generate last image
both images can not combine.
my code given below
$x = 363; $y = 267; $im_dest = imagecreatetruecolor ($x, $y); imagealphablending($im_dest, false); $im = imagecreatefrompng('2.png'); $im1 = imagecreatefrompng('1.png'); imagecopy($im_dest, $im1, 0, 0, 0, 0, $x, $y); imagecopy($im_dest, $im, 0, 0, 0, 0, $x, $y); imagesavealpha($im_dest, true); imagepng($im_dest, 'small_redfade.png');
these images using join in single image
imagemagick::composite can handle this, sadly haven't done in gd leave others explain how there.
something like:
<?php $firstimage = new imagick("firstimage.png"); $secondimage = new imagick("secondimage.png"); $firstimage->compositeimage($secondimage, imagick::composite_copyopacity, 0, 0 ); header('content-type: image/png'); echo $firstimage; ?>
this should preserve alpha.
Comments
Post a Comment