yii\imagine\BaseImage::frame PHP Method

frame() public static method

Adds a frame around of the image. Please note that the image size will increase by $margin x 2.
public static frame ( string | resource | Imagine\Image\ImageInterface $image, integer $margin = 20, string $color = '666', integer $alpha = 100 ) : Imagine\Image\ImageInterface
$image string | resource | Imagine\Image\ImageInterface either ImageInterface, resource or a string containing file path
$margin integer the frame size to add around the image
$color string the frame color
$alpha integer the alpha value of the frame.
return Imagine\Image\ImageInterface
    public static function frame($image, $margin = 20, $color = '666', $alpha = 100)
    {
        $img = static::getImagine()->open(Yii::getAlias($image));
        $size = $img->getSize();
        $pasteTo = new Point($margin, $margin);
        $palette = new RGB();
        $color = $palette->color($color, $alpha);
        $box = new Box($size->getWidth() + ceil($margin * 2), $size->getHeight() + ceil($margin * 2));
        $finalImage = static::getImagine()->create($box, $color);
        $finalImage->paste($img, $pasteTo);
        return $finalImage;
    }