/** * Create a new Image * * @param string $src * @param mixed style */ public function __construct($src, $style = null, $isWatermark = false) { $_supportedImageTypes = array('jpg', 'jpeg', 'gif', 'png', 'bmp', 'tif', 'tiff'); $inf = pathinfo($src); $ext = strtolower($inf['extension']); if (file_exists($src) && in_array($ext, $_supportedImageTypes)) { $this->_src = $src; $this->_isWatermark = $isWatermark; $this->_style = new PHPWord_Style_Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; } $this->_style->setStyleValue($key, $value); } } if (isset($style['wrappingStyle'])) { $this->_style->setWrappingStyle($style['wrappingStyle']); } if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { $imgData = getimagesize($this->_src); $this->_style->setWidth($imgData[0]); $this->_style->setHeight($imgData[1]); } return $this; } else { return false; } }
/** * Create a new Image * * @param string $src * @param mixed style */ public function __construct($src, $style = null) { $imgData = getimagesize($src); $this->_imageType = $imgData['mime']; $_supportedImageTypes = array('image/jpeg', 'image/gif', 'image/png'); if (in_array($this->_imageType, $_supportedImageTypes)) { $this->_src = $src; $this->_style = new PHPWord_Style_Image(); if (!is_null($style) && is_array($style)) { foreach ($style as $key => $value) { if (substr($key, 0, 1) != '_') { $key = '_' . $key; } $this->_style->setStyleValue($key, $value); } } if ($this->_style->getWidth() == null && $this->_style->getHeight() == null) { $this->_style->setWidth($imgData[0]); $this->_style->setHeight($imgData[1]); } $this->_setFunctions(); return $this; } else { return false; } }