Horde_Image_Base::__construct PHP Method

__construct() protected method

Constructor.
protected __construct ( array $params, array $context = [] )
$params array The image object parameters. Values include: - background: (string) The background color. DEFAULT: white. - data: (string) The image binary data. - height: (integer) The desired image height. - type: (string) The output image type (png, jpeg etc.). DEFAULT: png. - width: (integer) The desired image width.
$context array The object context - configuration, injected objects: - logger: (Horde_Log_Logger) A logger. - tmpdir: [REQUIRED] (string) Temporary directory.
    protected function __construct($params, $context = array())
    {
        $this->_params = $params;
        $this->_context = $context;
        if (empty($context['tmpdir'])) {
            throw new InvalidArgumentException('A path to a temporary directory is required.');
        }
        $this->_tmpdir = $context['tmpdir'];
        if (!empty($context['logger'])) {
            $this->_logger = $context['logger'];
        }
        if (isset($params['width'])) {
            $this->_width = $params['width'];
        }
        if (isset($params['height'])) {
            $this->_height = $params['height'];
        }
        if (!empty($params['type'])) {
            // We only want the extension, not the full mimetype.
            if (strpos($params['type'], 'image/') !== false) {
                $params['type'] = substr($params['type'], 6);
            }
            $this->_type = $params['type'];
        }
        if (!empty($params['background'])) {
            $this->_background = $params['background'];
        }
    }

Usage Example

Example #1
0
File: Png.php Project: horde/horde
 /**
  * PNG image constructor.
  */
 public function __construct($params, $context = array())
 {
     parent::__construct($params, $context);
     if (!empty($params['width'])) {
         $this->rectangle(0, 0, $params['width'], $params['height'], $this->_background, $this->_background);
     }
 }
All Usage Examples Of Horde_Image_Base::__construct