public create ( integer $width, integer | null $height = null, null | string $color = null ) | ||
$width | integer | Image width |
$height | integer | null | If omitted - assumed equal to $width |
$color | null | string | Hex color string, array(red, green, blue) or array(red, green, blue, alpha). Where red, green, blue - integers 0-255, alpha - integer 0-127 |
public function create($width, $height = null, $color = null)
{
$this->cleanup();
$height = $height ?: $width;
$this->_width = VarFilter::int($width);
$this->_height = VarFilter::int($height);
$this->_image = imagecreatetruecolor($this->_width, $this->_height);
$this->_mime = 'image/png';
$this->_exif = array();
$this->_orient = $this->_getOrientation();
if (null !== $color) {
return $this->addFilter('fill', $color);
}
return $this;
}
public function testCreateFromScratchFull() { $actual = Helper::getActual(__FUNCTION__ . '.png'); $excepted = Helper::getExpected(__FUNCTION__ . '.png'); $img = new Image(); $img->create(200, 100, array(0, 136, 204, 64))->saveAs($actual); Helper::isFileEq($actual, $excepted); }