protected function getDimensions($newWidth, $newHeight)
    {
        $usedRatio = $widthRatio = $this->width / $newWidth;
        $heightRatio = $this->height / $newHeight;

        if ($heightRatio < $widthRatio) {
            $usedRatio = $heightRatio;
        }

        $height = $this->height / $usedRatio;
        $width = $this->width / $usedRatio;

        return [$width, $height];
    }