是否可以拍摄此图片:
image1 http://i34.tinypic.com/2d8neo0.png
并应用此面具:
面具http://i35.tinypic.com/2091450.png
把它变成这个:
image2 http://i37.tinypic.com/23m7apv.png
使用GD还是Imagick?我知道可以使用形状来掩盖图像,但我不确定如何继续使用预先创建的透明图像.:■
小智 13
使用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;
Run Code Online (Sandbox Code Playgroud)
我认为您正在寻找imagealphablending。我用它来制作水印,我相信它会达到您想要的效果。
| 归档时间: |
|
| 查看次数: |
16525 次 |
| 最近记录: |