Instafilter\Filter::vignette PHP Method

vignette() public method

Adds a vignette to the image
public vignette ( string $color, integer $composition = Imagick::COMPOSITE_DEFAULT, float $crop_factor = 1.5 ) : Filter
$color string the colour of the vignette
$composition integer an imagick constant defining the composition to use
$crop_factor float defines the strenth of the vignette
return Filter
    public function vignette($color, $composition = \Imagick::COMPOSITE_DEFAULT, $crop_factor = 1.5)
    {
        $height = $this->imagick()->getImageHeight();
        $width = $this->imagick()->getImageWidth();
        $crop_x = floor($height * $crop_factor);
        $crop_y = floor($width * $crop_factor);
        $overlay = new \Imagick();
        $overlay->newPseudoImage($crop_x, $crop_y, "radial-gradient:rgba(0,0,0,0)-{$color}");
        $this->imagick()->compositeImage($overlay, $composition, ($width - $crop_x) / 2, ($height - $crop_y) / 2);
        return $this;
    }