mirror of
https://github.com/Intervention/image.git
synced 2025-08-12 08:54:03 +02:00
Added support for Image::fill() with array (RGB / RGBA)
This commit is contained in:
committed by
Stephan de Souza
parent
156f9d6f8a
commit
f528f608ec
@@ -216,6 +216,10 @@ abstract class AbstractDecoder
|
||||
*/
|
||||
public function isBase64()
|
||||
{
|
||||
if (!is_string($this->data)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return base64_encode(base64_decode($this->data)) === $this->data;
|
||||
}
|
||||
|
||||
@@ -238,6 +242,10 @@ abstract class AbstractDecoder
|
||||
*/
|
||||
private function decodeDataUrl($data_url)
|
||||
{
|
||||
if (!is_string($data_url)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$pattern = "/^data:(?:image\/[a-zA-Z\-\.]+)(?:charset=\".+\")?;base64,(?P<data>.+)$/";
|
||||
preg_match($pattern, $data_url, $matches);
|
||||
|
||||
|
@@ -22,6 +22,30 @@ class FillCommandTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGdFillArray()
|
||||
{
|
||||
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
||||
$image = Mockery::mock('Intervention\Image\Image');
|
||||
$image->shouldReceive('getCore')->once()->andReturn($resource);
|
||||
$image->shouldReceive('getWidth')->once()->andReturn(800);
|
||||
$image->shouldReceive('getHeight')->once()->andReturn(600);
|
||||
$command = new FillGd(array(array(50, 50, 50)));
|
||||
$result = $command->execute($image);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGdFillArrayWithAlpha()
|
||||
{
|
||||
$resource = imagecreatefromjpeg(__DIR__.'/images/test.jpg');
|
||||
$image = Mockery::mock('Intervention\Image\Image');
|
||||
$image->shouldReceive('getCore')->once()->andReturn($resource);
|
||||
$image->shouldReceive('getWidth')->once()->andReturn(800);
|
||||
$image->shouldReceive('getHeight')->once()->andReturn(600);
|
||||
$command = new FillGd(array(array(50, 50, 50, .50)));
|
||||
$result = $command->execute($image);
|
||||
$this->assertTrue($result);
|
||||
}
|
||||
|
||||
public function testGdFillWithCoordinates()
|
||||
{
|
||||
$driver = Mockery::mock('\Intervention\Image\Gd\Driver');
|
||||
|
Reference in New Issue
Block a user