/** * @param string $fileName * @param array $options * @param array $plugins */ public function __construct($fileName, $options = array(), array $plugins = array()) { parent::__construct($fileName, $options, $plugins); $this->determineFormat(); $this->verifyFormatCompatiblity(); switch ($this->format) { case 'GIF': $this->oldImage = @imagecreatefromgif($this->fileName); break; case 'JPG': $this->oldImage = @imagecreatefromjpeg($this->fileName); break; case 'PNG': $this->oldImage = @imagecreatefrompng($this->fileName); break; case 'STRING': $this->oldImage = @imagecreatefromstring($this->fileName); break; } if (!is_resource($this->oldImage)) { throw new \Exception('Invalid image file'); } else { $this->currentDimensions = array('width' => imagesx($this->oldImage), 'height' => imagesy($this->oldImage)); } }
/** * @param string $fileName * @param array $options * @param array $plugins */ public function __construct($fileName, $options = array(), array $plugins = array()) { parent::__construct($fileName, $options, $plugins); if (@$options['isDataStream'] && @$options['format']) { //*** $this->oldImage = imagecreatefromstring($fileName); //*** $this->setFormat($options['format']); //*** } else { //*** $this->determineFormat(); $this->verifyFormatCompatiblity(); switch ($this->format) { case 'GIF': $this->oldImage = imagecreatefromgif($this->fileName); break; case 'JPG': $this->oldImage = imagecreatefromjpeg($this->fileName); break; case 'PNG': $this->oldImage = imagecreatefrompng($this->fileName); break; case 'STRING': $this->oldImage = imagecreatefromstring($this->fileName); break; } } //*** $this->currentDimensions = array('width' => imagesx($this->oldImage), 'height' => imagesy($this->oldImage)); }
/** * * @param string $fileName * @param array $options * @param bool $isDataStream */ public function __construct($fileName, $options = array(), PluginCollection $plugins = null) { parent::__construct($fileName, $options, $plugins); $this->determineFormat(); $this->verifyFormatCompatiblity(); switch ($this->format) { case 'GIF': $this->oldImage = imagecreatefromgif($this->fileName); break; case 'JPG': $this->oldImage = imagecreatefromjpeg($this->fileName); break; case 'PNG': $this->oldImage = imagecreatefrompng($this->fileName); break; case 'STRING': $this->oldImage = imagecreatefromstring($this->fileName); break; } $this->currentDimensions = array('width' => imagesx($this->oldImage), 'height' => imagesy($this->oldImage)); }