php - Copy an Image with Drop Shadow and Tranparent Background -
i tried duplicate png image, has drop shadow (i.e. alpha channel) , transparent background. however, resulting image paints shadow , transparent background black. tried imagecopy
, imagecopymerge
; neither yielded valid results, aren't same original image.
$src = imagecreatefrompng('img_box3-bg.png'); /* using imagecopy. */ $dest = imagecreatetruecolor(116, 100); imagecopy($dest, $src, 0, 0, 0, 0, 116, 100); imagepng($dest, 'img_box3-bg.imagecopy.png'); imagedestroy($dest); /* using imagecopymerge. */ $dest2 = imagecreatetruecolor(116, 100); imagecopymerge($dest2, $src, 0, 0, 0, 0, 116, 100, 100); imagepng($dest2, 'img_box3-bg.imagecopymerge.png'); imagedestroy($dest2); imagedestroy($src);
help? beforehand.
something this:
$src = imagecreatefrompng('img_box3-bg.png'); /* using imagecopy. */ $dest = imagecreatetruecolor(116, 100); // new imagesavealpha($dest, true); $transparent = imagecolorallocatealpha($dest, 0, 0, 0, 127); imagefill($dest, 0, 0, $transparent); imagecopy($dest, $src, 0, 0, 0, 0, 116, 100); header('content-type: image/png'); imagepng($dest); imagedestroy($dest);
Comments
Post a Comment