我目前正在从base64 png创建一个图像,然后合并另一个PNG。我的代码如下,但temp.png仅仅是空的,即使$文件名的输出仍然是原来的图像:PHP GD图像不合并
session_start();
$email = $_SESSION['email'];
$img = $_POST['img'];
$img = str_replace('data:image/png;base64,', '', $img);
$img = str_replace(' ', '+', $img);
$fileData = base64_decode($img);
$fileName = "./gallery/" . bin2hex(openssl_random_pseudo_bytes(16)) . ".png";
file_put_contents($fileName, $fileData);
//Merge Two Images
header ("Content-type: image/png");
$background = imagecreatefrompng($fileName);
$pkt = imagecreatefrompng("./frames/frame1.png");
$insert_x = imagesx($pkt);
$insert_y = imagesy($pkt);
imagecopymerge($background,$pkt,0,0,0,0,$insert_x,$insert_y,100);
imagepng($background,"temp.png",100);
也许关于你的png透明度。检查[这个问题](http://stackoverflow.com/questions/5529306/i-cant-use-transparent-background-with-imagecopymerge) – cwps