PhpOffice\PhpPresentation\Shape\AbstractGraphic::setWidthAndHeight PHP Method

setWidthAndHeight() public method

Set width and height with proportional resize
Author: Vincent@luo MSN:[email protected]
public setWidthAndHeight ( integer $width, integer $height ) : PhpOffice\PhpPresentation\Shape\AbstractDrawing
$width integer
$height integer
return PhpOffice\PhpPresentation\Shape\AbstractDrawing
    public function setWidthAndHeight($width = 0, $height = 0)
    {
        $xratio = $width / $this->width;
        $yratio = $height / $this->height;
        if ($this->resizeProportional && !($width == 0 || $height == 0)) {
            if ($xratio * $this->height < $height) {
                $this->height = (int) ceil($xratio * $this->height);
                $this->width = $width;
            } else {
                $this->width = (int) ceil($yratio * $this->width);
                $this->height = $height;
            }
        }
        return $this;
    }