【问题标题】:place transparent image over non-transparent image将透明图像放在非透明图像上
【发布时间】:2013-01-08 14:23:07
【问题描述】:

我将上传的图片 ($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 上没有透明度,缺少什么?

【问题讨论】:

    标签: php


    【解决方案1】:

    唯一需要做的是:

    imagealphablending($new, true);
    

    没有

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

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

    【讨论】:

      猜你喜欢
      • 2016-03-12
      • 1970-01-01
      • 1970-01-01
      • 2023-04-11
      • 1970-01-01
      • 2011-07-20
      • 1970-01-01
      • 2010-12-01
      • 1970-01-01
      相关资源
      最近更新 更多