php - set alpha of each pixel in image
问题 I want to set the alpha of each pixel in image using php gd functions. So far i have this: $src = imagecreatefrompng('image.png'); $w = imagesx($src); $h = imagesy($src); $alpha = 204; for ($x = 0; $x < $w; $x++) { for ($y = 0; $y < $h; $y++) { // set $alpha for each pixel in $src } } imagepng($src); imagedestroy($src); 回答1: Alpha have to be defined into 0 and 127. Then you have to use imagealphablending() and imagesavealpha() to save and use alpha. $src = imagecreatefrompng('image.png');