public function getAspectRatio($respectOrientation = false) { if (!$this->hasDimensions()) { return 0; } $aspectRatio = $this->getWidth() / $this->getHeight(); if ($respectOrientation === false && $aspectRatio < 1) { $aspectRatio = 1 / $aspectRatio; } return $aspectRatio; }