imagesavealpha
imagesavealpha
Whether to retain full alpha channel information when saving images
true **imagesavealpha** GdImage $image bool $enable
sets the flag which determines whether to retain
full alpha channel information (as opposed to single-color transparency) when saving images. This is only supported for image formats which support full alpha channel information, i.e. , and .
imagesavealpha``PNG``WebP``AVIF> Opmerking: > is only meaningful for
images, since the full alpha channel is always saved for and . It is not recommended to rely on this behavior, as it may change in the future. Thus, should be called deliberately also for and images. `imagesavealpha``PNG``WebP``AVIF``imagesavealpha``WebP``AVIF`
Alphablending has to be disabled ()
to retain the alpha-channel in the first place.
imagealphablending($im, false)
enableWhether to save the alpha channel or not. Defaults to false.
return.true.always
Voorbeeld: Basic Usage
<?php
// Load a png image with alpha channel
$png = imagecreatefrompng('./alphachannel_example.png');
// Turn off alpha blending
imagealphablending($png, false);
// Do desired operations
// Set alpha flag
imagesavealpha($png, true);
// Output image to browser
header('Content-Type: image/png');
imagepng($png);
?>
imagealphablending