Set the flag to save full alpha channel information when saving PNG images in PHP

Description

The following code shows how to set the flag to save full alpha channel information when saving PNG images.

Example


<?php/*w  w w . j  a  v  a  2  s.  c o  m*/
// Load a png image with alpha channels
$png = imagecreatefrompng('./test.png');

// Do required operations

// Turn off alpha blending and set alpha flag
imagealphablending($png, false);
imagesavealpha($png, true);

// Output image to browser
header('Content-Type: image/png');

imagepng($png);
imagedestroy($png);
?>

The code above generates the following result.

Set the flag to save full alpha channel information when saving PNG images in PHP




















Home »
  PHP Tutorial »
    Image »




Color
Create
Font
Operation
Shape
Text