PHP | imagesavealpha() Function Last Updated : 19 Feb, 2020 Summarize Comments Improve Suggest changes Share Like Article Like Report The imagesavealpha() function is an inbuilt function in PHP which is used to set whether to retain full alpha channel information when saving PNG images or not. Alpha channel tells whether the image is fully transparent or opaque. Alpha blending has to be disabled using imagealphablending($im, false)) to retain the alpha-channel in the first place. Syntax: bool imagesavealpha( resource $image, bool $save_flag ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It specifies the image resource to work on. $save_flag: It specifies whether to save the alpha channel or not. Return Value: This function returns TRUE on success or FALSE on failure. Below examples illustrate the imagesavealpha() function in PHP: Example 1: In this example we will enable saving alpha info. php <?php // Load the png image $png = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Turn off alpha blending imagealphablending($png, false); // Add alpha as 100 to image $transparent = imagecolorallocatealpha($png, 255, 255, 255, 100); imagefill($png, 0, 0, $transparent); // Set alpha flag to true so that // alpha info is saved in the image imagesavealpha($png, true); // Save the image imagepng($png, 'imagewithalphainfo.png'); imagedestroy($png); ?> Output: This will save the image in the same folder as imagewithalphainfo.png with alpha info. Example 2: In this example we will disable saving alpha info. php <?php // Load the png image $png = imagecreatefrompng( 'https://media.geeksforgeeks.org/wp-content/uploads/geeksforgeeks-13.png'); // Turn off alpha blending imagealphablending($png, false); // Add alpha as 100 to image $transparent = imagecolorallocatealpha($png, 255, 255, 255, 100); imagefill($png, 0, 0, $transparent); // Set alpha flag to false so that // alpha info is not saved in the image imagesavealpha($png, false); // Save the image imagepng($png, 'imagewithoutalphainfo.png'); imagedestroy($png); ?> Output: This will save the image in the same folder as imagewithoutalphainfo.png without alpha info. Reference: https://www.php.net/manual/en/function.imagesavealpha.php Comment More infoAdvertise with us Next Article PHP | imagechar() Function G gurrrung Follow Improve Article Tags : Web Technologies PHP PHP-function PHP-image-functions Similar Reads PHP | imagewebp() Function The imagewebp() function is an inbuilt function in PHP which is used to display image to browser or file. The main use of this function is to view an image in the browser, convert any other image type to WebP and alter the quality of the image.Syntax:Â bool imagewebp( resource $image, int $to, int $q 2 min read PHP | imagechar() Function The imagechar() function is an inbuilt function in PHP which is used to draw a character horizontally. This function draws the first character of string in the image identified by image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagechar( $image, $font, $x, 2 min read PHP | imagechar() Function The imagechar() function is an inbuilt function in PHP which is used to draw a character horizontally. This function draws the first character of string in the image identified by image with its x and y-axis. The coordinate of the top-left corner is (0, 0). Syntax: bool imagechar( $image, $font, $x, 2 min read PHP | imagesettile() Function The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation 2 min read PHP | imagesettile() Function The imagesettile() function is an inbuilt function in PHP which is used to set the tile image for filling the area. Syntax: bool imagesettile( $image, $tile ) Parameters: This function accepts two parameters as mentioned above and described below: $image: It is returned by one of the image creation 2 min read PHP | imagecolorexactalpha() Function The imagecolorexactalpha() function is an inbuilt function in PHP which is used to get the index of the specified color with alpha value. This function returns the index of the specified color and alpha value (RGBA value) in the palette of the image. Syntax: int imagecolorexactalpha ( $image, $red, 2 min read Like