/**
* Constructor.
*
- * @param string $rgb The base color for generated pixels/images.
+ * @param array $params The image object parameters. Values include:
+ *<pre>
+ * (optional)width - The desired image width
+ * (optional)height - The desired image height
+ * (optional)type - The image type (png, jpeg etc...) If not provided,
+ * or set by the setType method, any image output will
+ * be converted to the default image type of png.
+ * (optional)data - The image binary data.
+ *</pre>
+ * @param array $context The object context - configuration, injected objects
*
* @throws InvalidArgumentException
*/
$this->_height = $params['height'];
}
if (!empty($params['type'])) {
+ // We only want the extension, not the full mimetype.
+ if (strpos($type, 'image/') !== false) {
+ $type = substr($type, 6);
+ }
$this->_type = $params['type'];
}
*/
public function setType($type)
{
+ // We only want the extension, not the full mimetype.
+ if (strpos($type, 'image/') !== false) {
+ $type = substr($type, 6);
+ }
$this->_type = $type;
}
public function __construct($params, $context = array())
{
parent::__construct($params, $context);
- if (!empty($params['width'])) {
+ if (!empty($params['filename'])) {
+ $this->loadFile($params['filename']);
+ } elseif (!empty($params['data'])) {
+ $this->loadString($params['data']);
+ } elseif (!empty($params['width'])) {
$this->_im = $this->create($this->_width, $this->_height);
$this->call('imageFill', array($this->_im, 0, 0, $this->_allocateColor($this->_background)));
}