mirror of
https://github.com/Intervention/image.git
synced 2025-09-02 18:32:56 +02:00
Change default background/blending colors
This commit is contained in:
@@ -18,6 +18,6 @@ class TransparentColorDecoder extends HexColorDecoder
|
||||
throw new DecoderException('Unable to decode input');
|
||||
}
|
||||
|
||||
return parent::decode('#ff00ff00');
|
||||
return parent::decode('#ffffff00');
|
||||
}
|
||||
}
|
||||
|
@@ -47,7 +47,7 @@ class Driver extends AbstractDriver
|
||||
// build new transparent GDImage
|
||||
$data = imagecreatetruecolor($width, $height);
|
||||
imagesavealpha($data, true);
|
||||
$background = imagecolorallocatealpha($data, 255, 0, 255, 127);
|
||||
$background = imagecolorallocatealpha($data, 255, 255, 255, 127);
|
||||
imagealphablending($data, false);
|
||||
imagefill($data, 0, 0, $background);
|
||||
imagecolortransparent($data, $background);
|
||||
|
@@ -46,7 +46,7 @@ class Driver extends AbstractDriver
|
||||
*/
|
||||
public function createImage(int $width, int $height): ImageInterface
|
||||
{
|
||||
$background = new ImagickPixel('rgba(0, 0, 0, 0)');
|
||||
$background = new ImagickPixel('rgba(255, 255, 255, 0)');
|
||||
|
||||
$imagick = new Imagick();
|
||||
$imagick->newImage($width, $height, $background, 'png');
|
||||
@@ -54,6 +54,7 @@ class Driver extends AbstractDriver
|
||||
$imagick->setImageType(Imagick::IMGTYPE_UNDEFINED);
|
||||
$imagick->setColorspace(Imagick::COLORSPACE_SRGB);
|
||||
$imagick->setImageResolution(96, 96);
|
||||
$imagick->setImageBackgroundColor($background);
|
||||
|
||||
return new Image($this, new Core($imagick));
|
||||
}
|
||||
|
@@ -138,6 +138,6 @@ class GdInputHandlerTest extends TestCase
|
||||
$input = 'transparent';
|
||||
$result = $handler->handle($input);
|
||||
$this->assertInstanceOf(RgbColor::class, $result);
|
||||
$this->assertEquals([255, 0, 255, 0], $result->toArray());
|
||||
$this->assertEquals([255, 255, 255, 0], $result->toArray());
|
||||
}
|
||||
}
|
||||
|
@@ -138,6 +138,6 @@ class InputHandlerTest extends TestCase
|
||||
$input = 'transparent';
|
||||
$result = $handler->handle($input);
|
||||
$this->assertInstanceOf(RgbColor::class, $result);
|
||||
$this->assertEquals([255, 0, 255, 0], $result->toArray());
|
||||
$this->assertEquals([255, 255, 255, 0], $result->toArray());
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user