6

Im trying to copy a image(a.png) on another. Both contain transparency. a.png shows up with a white background on save.

$base=imagecreatefrompng("base.png");
imagealphablending( $base, false );
imagesavealpha( $base, true );
$temp=imagecreatefrompng('a.png');
imagecopymerge($base,$temp,64,144,0,0,16,16,100);
genesis
  • 50,477
  • 20
  • 96
  • 125
GUIpsp
  • 151
  • 2
  • 9

1 Answers1

10

Try this:

$base=imagecreatefrompng("base.png");
imagealphablending( $base, true );
imagesavealpha( $base, true );
$temp=imagecreatefrompng('a.png');
imagecopy($base,$temp,64,144,0,0,16,16);
Mike C
  • 1,808
  • 15
  • 17
  • 1
    @GUIpsp Try running the function on this page: http://www.exorithm.com/algorithm/view/overlay_image . Is that the effect you are looking for? – Mike C Mar 23 '11 at 19:06
  • Yes thats it i was using imagecopymerge instead of imagecopy, thanks! – GUIpsp Mar 23 '11 at 21:08
  • Doesn't work for me, all transparent pixels in $temp as coped over as black. With both imagecopy() and imagecopymerge() and imagecopymerge_alpha() – Curtis Aug 13 '18 at 05:15