public function paddedResize($width, $height, $backgroundColor = "FFFFFF", $transparencyPercent = 0)
    {
        $resource = $this->getImageResource();
        if (!$resource) {
            return null;
        }

        // caclulate the background colour
        $background = $resource->getDriver()->parseColor($backgroundColor)->format('array');
        // convert transparancy % to alpha
        $background[3] = 1 - round(min(100, max(0, $transparencyPercent)) / 100, 2);

        // resize the image maintaining the aspect ratio and then pad out the canvas
        return $this->createCloneWithResource(
            function (InterventionImage $resource) use ($width, $height, $background) {
                return $resource
                    ->resize(
                        $width,
                        $height,
                        function (Constraint $constraint) {
                            $constraint->aspectRatio();
                        }
                    )
                    ->resizeCanvas(
                        $width,
                        $height,
                        'center',
                        false,
                        $background
                    );
            }
        );
    }
public function paddedResize($width, $height, $backgroundColor = "FFFFFF", $transparencyPercent = 0)
    {
        $resource = $this->getImageResource();
        if (!$resource) {
            return null;
        }

        // caclulate the background colour
        $background = $resource->getDriver()->parseColor($backgroundColor)->format('array');
        // convert transparancy % to alpha
        $background[3] = 1 - round(min(100, max(0, $transparencyPercent)) / 100, 2);

        // resize the image maintaining the aspect ratio and then pad out the canvas
        return $this->createCloneWithResource(
            function (InterventionImage $resource) use ($width, $height, $background) {
                return $resource
                    ->resize(
                        $width,
                        $height,
                        function (Constraint $constraint) {
                            $constraint->aspectRatio();
                        }
                    )
                    ->resizeCanvas(
                        $width,
                        $height,
                        'center',
                        false,
                        $background
                    );
            }
        );
    }
public function paddedResize ( $ width , $ height , $ backgroundColor = "FFFFFF" , $ transparencyPercent = 0 ) { $ resource = $ this -> getImageResource ( ) ; if ( ! $ resource ) { return null ; } // caclulate the background colour $ background = $ resource -> getDriver ( ) -> parseColor ( $ backgroundColor ) -> format ( 'array' ) ; // convert transparancy % to alpha $ background [ 3 ] = 1 - round ( min ( 100 , max ( 0 , $ transparencyPercent ) ) / 100 , 2 ) ; // resize the image maintaining the aspect ratio and then pad out the canvas return $ this -> createCloneWithResource ( function ( InterventionImage $ resource ) use ( $ width , $ height , $ background ) { return $ resource -> resize ( $ width , $ height , function ( Constraint $ constraint ) { $ constraint -> aspectRatio ( ) ; } ) -> resizeCanvas ( $ width , $ height , 'center' , false , $ background ) ; } ) ; }
Return a clone of this image resized, with space filled in with the given colour

@param int $width
@param int $height
@param string $backgroundColor
@param int $transparencyPercent
@return static
Return a clone of this image resized with space filled in with the given colour