name = ''; $this->description = ''; $this->resizeProportional = true; // Set image index ++self::$imageCounter; $this->imageIndex = self::$imageCounter; // Initialize parent parent::__construct(); } public function __clone() { parent::__clone(); ++self::$imageCounter; $this->imageIndex = self::$imageCounter; } /** * Get image index. * * @return int */ public function getImageIndex() { return $this->imageIndex; } /** * Get Name. * * @return string */ public function getName() { return $this->name; } /** * Set Name. * * @param string $pValue * * @return $this */ public function setName($pValue = '') { $this->name = $pValue; return $this; } /** * Get Description. * * @return string */ public function getDescription() { return $this->description; } /** * Set Description. * * @param string $pValue * * @return $this */ public function setDescription($pValue = '') { $this->description = $pValue; return $this; } /** * Set Width. * * @return self */ public function setWidth(int $pValue = 0) { // Resize proportional? if ($this->resizeProportional && 0 != $pValue && 0 != $this->width) { $ratio = $this->height / $this->width; $this->height = (int) \round($ratio * $pValue); } // Set width $this->width = $pValue; return $this; } /** * Set Height. * * @return self */ public function setHeight(int $pValue = 0) { // Resize proportional? if ($this->resizeProportional && 0 != $pValue && 0 != $this->height) { $ratio = $this->width / $this->height; $this->width = (int) \round($ratio * $pValue); } // Set height $this->height = $pValue; return $this; } /** * Set width and height with proportional resize. * * @author Vincent@luo MSN:kele_100@hotmail.com * * @return self */ public function setWidthAndHeight(int $width = 0, int $height = 0) { $xratio = $width / $this->width; $yratio = $height / $this->height; if ($this->resizeProportional && !(0 == $width || 0 == $height)) { 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; } /** * Get ResizeProportional. * * @return bool */ public function isResizeProportional() { return $this->resizeProportional; } /** * Set ResizeProportional. * * @param bool $pValue */ public function setResizeProportional($pValue = true): self { $this->resizeProportional = $pValue; return $this; } /** * Get hash code. * * @return string Hash code */ public function getHashCode(): string { return \md5($this->name . $this->description . parent::getHashCode() . __CLASS__); } }