mPDF Manual – mPDF functions

SetAlpha()

(mPDF >= 1.0)

SetAlpha – Set the opacity for Images

Description

void SetAlpha ( float $alpha [, integer $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) to 1 (opaque)

$blend

This parameter specifies the blend mode.

Values

STRING - One of the following:

Normal

Multiply

Screen

Overlay

Darken

Lighten

ColorDodge

ColorBurn

HardLight

SoftLight

Difference

Exclusion

Hue

Saturation

Color

Luminosity

DEFAULT: Normal

Changelog

VersionDescription
1.0 Function was added.

Examples

Example #1

<?php

// Require composer autoload
require_once __DIR__ . '/vendor/autoload.php';

$mpdf = new 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