public function resizeAspectRatio($newX, $newY, $fillRed = 255, $fillGreen = 255, $fillBlue = 255)
    {
        if (!is_numeric($newX) || !is_numeric($newY)) {
            throw new ImageUtilException('There are no valid values');
        }

        $image = $this->image;

        if (imagesy($image) >= $newY || imagesx($image) >= $newX) {
            if (imagesx($image) >= imagesy($image)) {
                $curX = $newX;
                $curY = ($curX * imagesy($image)) / imagesx($image);
                $yyy = -($curY - $newY) / 2;
                $xxx = 0;
            } else {
                $curY = $newY;
                $curX = ($curY * imagesx($image)) / imagesy($image);
                $xxx = -($curX - $newX) / 2;
                $yyy = 0;
            }
        } else {
            $curX = imagesx($image);
            $curY = imagesy($image);
            $yyy = 0;
            $xxx = 0;
        }

        $imw = imagecreatetruecolor($newX, $newY);
        $color = imagecolorallocate($imw, $fillRed, $fillGreen, $fillBlue);
        imagefill($imw, 0, 0, $color);
        imagealphablending($imw, false);

        imagecopyresampled($imw, $image, $xxx, $yyy, 0, 0, $curX, $curY, imagesx($image), imagesy($image));

        $this->image = $imw;

        return $this;
    }