PHP 8.5.0 Alpha 1 available for testing

Voting

: max(zero, zero)?
(Example: nine)

The Note You're Voting On

olivier dot pons at google dot mail dot com
12 years ago
I wanted to clear an image, and set it to full transparent.
imagefilledrectangle() seems to ignore alpha channel and alpha blending.
Use imagefill() instead:

<?php
$w
= imagesx($final);
$h = imagesy($final);
$grande = imagecreatetruecolor($w, $h);

// Alpha blending on to use channel alpha
imagealphablending($grande, true);
// Allocate a transparent color and fill the new image with it.
// Without this the image will have a black background instead
// of being transparent.
$transparent = imagecolorallocatealpha($grande, 0, 0, 0, 127);
// transparent alpha will be _ignored_:
imagefilledrectangle($grande, 0, 0, $w, $h, $transparent);
// ok, transparent will be used and set whole alpha channel to transparent:
imagefill($grande, 0, 0, $transparent);
?>

<< Back to user notes page

To Top