是否可以拍摄此图像:
并应用此掩码:
并将其变成这样:
使用 GD 还是 Imagick?我知道可以使用形状来遮盖图像,但我不确定如何继续使用预先创建的 alpha 透明图像来完成此操作。 :s
Is it possible to take this image:
And apply this mask:
And turn it into this:
Using either GD or Imagick? I know it's possible to mask an image using shapes but I'm not sure how to go on about doing it with a pre-created alphatransparent image. :s
使用Imagick和ImageMagick版本> 6(我不知道它是否适用于旧版本):
// Set image path $path = '/path/to/your/images/'; // Create new objects from png's $dude = new Imagick($path . 'dude.png'); $mask = new Imagick($path . 'dudemask.png'); // IMPORTANT! Must activate the opacity channel // See: http://www.php.net/manual/en/function.imagick-setimagematte.php $dude->setImageMatte(1); // Create composite of two images using DSTIN // See: http://www.imagemagick.org/Usage/compose/#dstin $dude->compositeImage($mask, Imagick::COMPOSITE_DSTIN, 0, 0); // Write image to a file. $dude->writeImage($path . 'newimage.png'); // And/or output image directly to browser header("Content-Type: image/png"); echo $dude;
Using Imagick and ImageMagick version > 6 (I don't know if it will work on older versions):
我认为您正在寻找 imagealphablending。我用它来制作水印,我相信它会达到您想要的效果。
I think you are looking for imagealphablending. I use it for watermarks, and I believe it will do the effect you are looking for.
与(ImageMagick)合作得很好,不是 GD ..我看到这个问题的标签是 GD!
这是 GD 版本,链接如下: PHP GD 使用一张图像遮盖另一张图像,包括透明度
Great work with (ImageMagick) NOT GD .. I see the tags of this question is GD!!
Here is a GD version at this link: PHP GD Use one image to mask another image, including transparency
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(3)
使用Imagick和ImageMagick版本> 6(我不知道它是否适用于旧版本):
Using Imagick and ImageMagick version > 6 (I don't know if it will work on older versions):
我认为您正在寻找 imagealphablending。我用它来制作水印,我相信它会达到您想要的效果。
I think you are looking for imagealphablending. I use it for watermarks, and I believe it will do the effect you are looking for.
与(ImageMagick)合作得很好,不是 GD ..我看到这个问题的标签是 GD!
这是 GD 版本,链接如下:
PHP GD 使用一张图像遮盖另一张图像,包括透明度
Great work with (ImageMagick) NOT GD .. I see the tags of this question is GD!!
Here is a GD version at this link:
PHP GD Use one image to mask another image, including transparency