SetAlpha()
(mPDF ≥ 1.0)
SetAlpha – Set the opacity for Images
Description
void SetAlpha ( float $alpha [, string $blend ])
Set the opacity and blend mode for Images
Parameters
- $alpha
-
This parameter specifies the opacity for any subsequent images written to the current document.
Values
Float:
0
(transparent) to1
(opaque) - $blend
-
This parameter specifies the blend mode.
Values
One of the following strings:
'Normal'
'Multiply'
'Screen'
'Overlay'
'Darken'
'Lighten'
'ColorDodge'
'ColorBurn'
'HardLight'
'SoftLight'
'Difference'
'Exclusion'
'Hue'
'Saturation'
'Color'
'Luminosity'
Default:
'Normal'
Changelog
Version | Description |
---|---|
1.0 | Function was added. |
Examples
Example #1
<?php
// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';
$mpdf = new \Mpdf\Mpdf();
$mpdf->SetAlpha(0.5);
$mpdf->WriteHTML('<img src="clematis.jpg" />');
$mpdf->SetAlpha(1);
// This produces the identical result as the last 3 lines
// $mpdf->WriteHTML('<img src="clematis.jpg" opacity="0.5" />');
$mpdf->Output();
exit;
See Also
- Image() - Write an image to the current document