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 * * @param int $pValue * @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic */ public function setWidth($pValue = 0) { // Resize proportional? if ($this->resizeProportional && $pValue != 0 && $this->width != 0) { $ratio = $this->height / $this->width; $this->height = (int) round($ratio * $pValue); } // Set width $this->width = $pValue; return $this; } /** * Set Height * * @param int $pValue * @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic */ public function setHeight($pValue = 0) { // Resize proportional? if ($this->resizeProportional && $pValue != 0 && $this->height != 0) { $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 * @param int $width * @param int $height * @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic */ 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; } /** * Get ResizeProportional * * @return boolean */ public function isResizeProportional() { return $this->resizeProportional; } /** * Set ResizeProportional * * @param boolean $pValue * @return \PhpOffice\PhpPresentation\Shape\AbstractGraphic */ public function setResizeProportional($pValue = true) { $this->resizeProportional = $pValue; return $this; } /** * Get hash code * * @return string Hash code */ public function getHashCode() { return md5($this->name . $this->description . parent::getHashCode() . __CLASS__); } }