Convert opacity value to alpha
public static opacity2Alpha ( integer $opacity ) : integer | ||
$opacity | integer | |
Résultat | integer |
/** * Set colorize * * @param resource $image Image GD resource * @param string $color Hex color string, array(red, green, blue) or array(red, green, blue, alpha). * Where red, green, blue - integers 0-255, alpha - integer 0-127 * @param float|int $opacity 0-100 * @return $this * * @throws \JBZoo\Utils\Exception */ public static function colorize($image, $color, $opacity) { $rgba = Helper::normalizeColor($color); $alpha = Helper::opacity2Alpha($opacity); $red = Helper::color($rgba[0]); $green = Helper::color($rgba[1]); $blue = Helper::color($rgba[2]); imagefilter($image, IMG_FILTER_COLORIZE, $red, $green, $blue, $alpha); }