2013-01-08 160 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);