0

我将上传的图像 ($image) 裁剪为固定大小。

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

我读到 imagealphablending 和 imagesavealpha 应该这样设置。$image 不透明。

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

是应该放在顶部的图像,我读到它应该具有这些设置。$new 和 $cover 现在的大小完全相同。

然后我将 $cover 复制到 $new 上,应该显示因为 $cover 是透明的

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

但是它放在 $new 上没有透明度,缺少什么?

4

1 回答 1

0

唯一需要做的是:

imagealphablending($new, true);

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

或者

imagealphablending($cover, false);
imagesavealpha($cover, true);
于 2013-01-08T14:49:56.890 回答