SimpleImage::colorize PHP Method

colorize() public method

Colorize
public colorize ( string $color, float | integer $opacity ) : SimpleImage
$color string Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127
$opacity float | integer 0-1
return SimpleImage
    function colorize($color, $opacity)
    {
        $rgba = $this->normalize_color($color);
        $alpha = $this->keep_within(127 - 127 * $opacity, 0, 127);
        imagefilter($this->image, IMG_FILTER_COLORIZE, $this->keep_within($rgba['r'], 0, 255), $this->keep_within($rgba['g'], 0, 255), $this->keep_within($rgba['b'], 0, 255), $alpha);
        return $this;
    }