mirror of
https://github.com/Intervention/image.git
synced 2025-08-01 11:30:16 +02:00
imagick fill restores alpha channel
This commit is contained in:
@@ -64,9 +64,15 @@ class FillCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
// mask away color at pos.
|
||||
$tile->paintTransparentImage($tile->getImagePixelColor($x, $y), 0, 0);
|
||||
|
||||
// save alpha channel of original image
|
||||
$alpha = clone $image->getCore();
|
||||
|
||||
// merge original with canvas and tile
|
||||
$image->getCore()->compositeImage($canvas, \Imagick::COMPOSITE_DEFAULT, 0, 0);
|
||||
$image->getCore()->compositeImage($tile, \Imagick::COMPOSITE_DEFAULT, 0, 0);
|
||||
|
||||
// restore alpha channel of original image
|
||||
$image->getCore()->compositeImage($alpha, \Imagick::COMPOSITE_COPYOPACITY, 0, 0);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
@@ -56,7 +56,7 @@ class FillCommandTest extends PHPUnit_Framework_TestCase
|
||||
$imagick = Mockery::mock('Imagick');
|
||||
$imagick->shouldReceive('getimagepixelcolor')->once()->andReturn('#000000');
|
||||
$imagick->shouldReceive('painttransparentimage')->once()->andReturn(true);
|
||||
$imagick->shouldReceive('compositeimage')->times(2)->andReturn(true);
|
||||
$imagick->shouldReceive('compositeimage')->times(3)->andReturn(true);
|
||||
$image = Mockery::mock('Intervention\Image\Image');
|
||||
$image->shouldReceive('getCore')->andReturn($imagick);
|
||||
$image->shouldReceive('getWidth')->andReturn(800);
|
||||
|
Reference in New Issue
Block a user