public function scale_and_crop($width, $height)
    {
        if ($width === null) {
            throw new \LogicException('"width" must not be null for "scale_and_crop"');
        }

        if ($height === null) {
            throw new \LogicException('"height" must not be null for "scale_and_crop"');
        }

        $scale = max($width / $this->getWidth(), $height / $this->getHeight());
        $w = ceil($this->getWidth() * $scale);
        $h = ceil($this->getHeight() * $scale);
        $x = ($w - $width) / 2;
        $y = ($h - $height) / 2;

        $this->resize($w, $h);
        $this->crop($x, $y, $width, $height);
    }