public function imageBorder($params)
    {
        if (is_array($params)) {
            $filename = $params['source'];
            $ext = $this->imageExtension($filename);
            if ($ext === 'png') {
                $image = imagecreatefromstring(file_get_contents($filename));
            } elseif ($ext === 'jpeg') {
                $image = imagecreatefromjpeg($filename);
            } elseif ($ext === 'gif') {
                $image = imagecreatefromgif($filename);
            } else {
                return false;
            }
            $border_colors = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
            $x = 0;
            $y = 0;
            $w = imagesx($image) - 1;
            $h = imagesy($image) - 1;
            imagesetthickness($image, $params['thickness']);
            //left
            imageline($image, $x, $y, $x, $y + $h, $border_colors);
            //top
            imageline($image, $x, $y, $x + $w, $y, $border_colors);
            //right
            imageline($image, $x + $w, $y, $x + $w, $y + $h, $border_colors);
            //bottom
            imageline($image, $x, $y + $h, $x + $w, $y + $h, $border_colors);
            imagejpeg($image);
            if (isset($params['save']) and $params['save'] === true) {
                $this->imageSave([
                    'image'  => $image,
                    'target' => $params['target'], ]);
            }
            imagedestroy($image);
        } else {
            return false;
        }
    }
public function imageBorder($params)
    {
        if (is_array($params)) {
            $filename = $params['source'];
            $ext = $this->imageExtension($filename);
            if ($ext === 'png') {
                $image = imagecreatefromstring(file_get_contents($filename));
            } elseif ($ext === 'jpeg') {
                $image = imagecreatefromjpeg($filename);
            } elseif ($ext === 'gif') {
                $image = imagecreatefromgif($filename);
            } else {
                return false;
            }
            $border_colors = imagecolorallocate($image, $params['bg_color']['red'], $params['bg_color']['green'], $params['bg_color']['blue']);
            $x = 0;
            $y = 0;
            $w = imagesx($image) - 1;
            $h = imagesy($image) - 1;
            imagesetthickness($image, $params['thickness']);
            //left
            imageline($image, $x, $y, $x, $y + $h, $border_colors);
            //top
            imageline($image, $x, $y, $x + $w, $y, $border_colors);
            //right
            imageline($image, $x + $w, $y, $x + $w, $y + $h, $border_colors);
            //bottom
            imageline($image, $x, $y + $h, $x + $w, $y + $h, $border_colors);
            imagejpeg($image);
            if (isset($params['save']) and $params['save'] === true) {
                $this->imageSave([
                    'image'  => $image,
                    'target' => $params['target'], ]);
            }
            imagedestroy($image);
        } else {
            return false;
        }
    }
public function imageBorder ( $ params ) { if ( is_array ( $ params ) ) { $ filename = $ params [ 'source' ] ; $ ext = $ this -> imageExtension ( $ filename ) ; if ( $ ext === 'png' ) { $ image = imagecreatefromstring ( file_get_contents ( $ filename ) ) ; } elseif ( $ ext === 'jpeg' ) { $ image = imagecreatefromjpeg ( $ filename ) ; } elseif ( $ ext === 'gif' ) { $ image = imagecreatefromgif ( $ filename ) ; } else { return false ; } $ border_colors = imagecolorallocate ( $ image , $ params [ 'bg_color' ] [ 'red' ] , $ params [ 'bg_color' ] [ 'green' ] , $ params [ 'bg_color' ] [ 'blue' ] ) ; $ x = 0 ; $ y = 0 ; $ w = imagesx ( $ image ) - 1 ; $ h = imagesy ( $ image ) - 1 ; imagesetthickness ( $ image , $ params [ 'thickness' ] ) ; //left imageline ( $ image , $ x , $ y , $ x , $ y + $ h , $ border_colors ) ; //top imageline ( $ image , $ x , $ y , $ x + $ w , $ y , $ border_colors ) ; //right imageline ( $ image , $ x + $ w , $ y , $ x + $ w , $ y + $ h , $ border_colors ) ; //bottom imageline ( $ image , $ x , $ y + $ h , $ x + $ w , $ y + $ h , $ border_colors ) ; imagejpeg ( $ image ) ; if ( isset ( $ params [ 'save' ] ) and $ params [ 'save' ] === true ) { $ this -> imageSave ( [ 'image' => $ image , 'target' => $ params [ 'target' ] , ] ) ; } imagedestroy ( $ image ) ; } else { return false ; } }
Add Border to the image.

@param   $params (array)
'source' => Source valid image file
'thickness' => thickness of border
'bg_color' =>  three argument valid value for rgb
'red' => red color
'green' => green color
'blue' => blue color
Learn more about rgb https://en.wikipedia.org/wiki/RGB_color_model
if you do not want save image these parameter are optional if you want save image
'save' => true
'target' => target + new name of file

@since 1.0.0

@return image
Add Border to the image .