2013-01-08 165 views
0

我将上传的图像($图像)裁剪为固定大小。在透明图像上放置透明图像

$new = imagecreatetruecolor($width, $height); 
imagealphablending($new, false); 
imagesavealpha($new, true); 
imagecopyresampled($new, $image, 0, 0, $x, $y, $width, $height, $width, $height); 

我读了imagealphablending和imagesavealpha应该像那样设置。 $图像不透明。

$cover = imagecreatefrompng('../img/magazine2.png'); 
imagealphablending($cover, false); 
imagesavealpha($cover, true); 

是应该放在顶部的图像,我读了它应该有这些设置。 $新和$封面现在是完全相同的大小。

然后我复制$超过$新,这应该显示支付,因为$盖是透明

imagecopy($new, $cover, 0, 0, 0, 0, $width, $height); 

但它放置在$新的不透明度,缺什么?

回答

0

是必须做的唯一事情是这样的:

imagealphablending($new, true); 

没有

imagealphablending($new, false); 
imagesavealpha($new, true); 

imagealphablending($cover, false); 
imagesavealpha($cover, true);