PHP 4 >= 4.3.2, PHP 5, PHP 7, PHP 8
imagesavealpha - Whether to retain full alpha channel information when saving PNG images
Code Examples

imagesavealpha( GdImage$image, bool$enable ): bool

imagesavealpha sets the flag which determines whether to retain full alpha channel information (as opposed to single-color transparency) when saving PNG images.

Alphablending has to be disabled (imagealphablending($im, false)) to retain the alpha-channel in the first place.



A GdImage object, returned by one of the image creation functions, such as imagecreatetruecolor.


Whether to save the alpha channel or not. Defaults to false.

Return Values

Returns true on success or false on failure.


Version Description
8.0.0 image expects a GdImage instance now; previously, a resource was expected.

Related Functions

Example of imagesavealpha

Show all examples for imagesavealpha

PHP Version:

Function imagesavealpha:

Image Processing and GD Functions

Most used PHP functions