public function scaleToOuterBox($width, $height, $saveAsNewFile = false)
    {
        $width_ratio = $width == 0 ? $height / $this->getHeight() : $width / $this->getWidth();
        $height_ratio = $height == 0 ? $width / $this->getWidth() : $height / $this->getHeight();
        if ($width_ratio < $height_ratio) {
            return $this->forceSize($this->getWidth() * $width_ratio, 0, $saveAsNewFile);
        }

        return $this->forceSize(0, $this->getHeight() * $height_ratio, $saveAsNewFile);

    }