1
0
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:
Oliver Vogel
2024-01-06 14:38:19 +01:00
parent 38fa2df2e3
commit 99150c4e1d
5 changed files with 6 additions and 5 deletions

View File

@@ -18,6 +18,6 @@ class TransparentColorDecoder extends HexColorDecoder
throw new DecoderException('Unable to decode input');
}
return parent::decode('#ff00ff00');
return parent::decode('#ffffff00');
}
}

View File

@@ -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);

View File

@@ -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));
}

View File

@@ -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());
}
}

View File

@@ -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());
}
}