开发者

PHP png image compositing [duplicate]

开发者 https://www.devze.com 2023-03-25 02:55 出处:网络
This question already has answers here: Closed 11 years ago. Possible Duplicate: How to merge transparent PNG with image using PHP?
This question already has answers here: Closed 11 years ago.

Possible Duplicate:

How to merge transparent PNG with image using PHP?

I am completely lost here, so help would be greatly appreciated. I am new to PHP image manipulation.

I have two semi-transparent png files, and I would like to overlay one over the other and output the resulting png.

Thanks in advanced.

EDIT:

  1. GD, though I can change that if needed.
  2. So far I've hacked this together from what I could find on the internet. It does not wo开发者_StackOverflow中文版rk.


imagecopymerge would be the solution

header("Content-Type: image/png");

$overlay = imagecreatefrompng("overlay.png");
$overlay_width = imagesx($overlay);
$overlay_height = imagesy($overlay);
$im = imagecreatefrompng("firstimage.png");
$width = imagesx($im);
$height = imagesy($im);
$dest_x = 0;
$dest_y = 0;
imagecopymerge($im, $overlay, $dest_x, $dest_y, 0, 0, $overlay_width, $overlay_height, 100);

imagepng($im);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号