_getDimensions(); return $height; } public function getWidth() { list ($width,) = $this->_getDimensions(); return $width; } private function _getDimensions() { if (!isset($this->_width) || !isset($this->_height)) { $image = imagecreatefromstring($this->image); $this->_width = imagesx($image); $this->_height = imagesy($image); if ($this->_height >= $this->_width * self::MAX_HEIGHT / self::MAX_WIDTH && $this->_height > self::MAX_HEIGHT) { $newHeight = self::MAX_HEIGHT; $newWidth = floor($width * $newHeight / $height); $this->_height = $newHeight; $this->_width = $newWidth; } elseif ($this->_height < $this->_width * self::MAX_HEIGHT / self::MAX_WIDTH && $this->_width > self::MAX_WIDTH) { $newWidth = self::MAX_WIDTH; $newHeight = floor($newWidth * $this->_height / $this->_width); $this->_height = $newHeight; $this->_width = $newWidth; } } return array($this->_width, $this->_height); } }