wiImage::merge()
See:
List of operations
Signature
wiImage::merge($overlay, $x = 0, $y = 0, $pct = 100)
Parameters
- $overlay (wiImage): the overlay (watermark) image to merge on the base image.
- $x (int, string): x destination coordinate. Can be an integer or a percent string.
- $y (int, string): y destination coordinate. Can be an integer or a percent string.
- $pct (int) opacity (0..100)
- result (wiTrueColorImage): merged image
Description
This will merge (blend) the overlay image onto the base image at location ($x, $y) with $pct opacity using
imagecopymerge()∞.
Notes
- For $pct=0, the method will return a true-color copy of $baseImage. For $pct=100, it will use imagecopy()∞.
- For alpha-transparent overlays, you should use $pct=100 (default) in order to have the desired effect. The alpha channel is used as the opacity for any given pixel. You can't combine alpha channel with merge opacity.
Examples
$picture = wiImage::load('/path/to/another/image.png');
$overlay = wiImage::load('/path/to/watermark.png');
$result = $picture->merge($overlay, 10, 10, 50);
// or with an image that has alpha channel
$alpha_overlay = wiImage::load('/path/to/alpha/overlay.png');
$picture->merge($alpha_overlay, 10, 10)->saveToFile(...);
// with percent string
$new = $picture->merge($overlay, '50%', '25%', 40);
CategoryDocApi
There are no comments on this page. [Add comment]