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
                    );
            }
        );
    }