mirror of
https://github.com/Intervention/image.git
synced 2025-08-20 12:41:23 +02:00
fixed bug for emerging colors when using resizeCanvas
This commit is contained in:
@@ -61,6 +61,12 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
|
||||
$src_h = $original_height;
|
||||
}
|
||||
|
||||
// make image area transparent to keep transparency
|
||||
// even if background-color is set
|
||||
$transparent = imagecolorallocatealpha($canvas->getCore(), 0, 0, 0, 127);
|
||||
imagealphablending($canvas->getCore(), false); // do not blend / just overwrite
|
||||
imagefilledrectangle($canvas->getCore(), $dst_x, $dst_y, $src_w + 1, $src_h + 1, $transparent);
|
||||
|
||||
// copy image into new canvas
|
||||
imagecopy($canvas->getCore(), $image->getCore(), $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h);
|
||||
|
||||
|
@@ -22,7 +22,7 @@ class ResizeCanvasCommandTest extends PHPUnit_Framework_TestCase
|
||||
$image_size->shouldReceive('align')->with('center')->andReturn($image_size);
|
||||
$image_size->shouldReceive('relativePosition')->andReturn($image_pos);
|
||||
$canvas = Mockery::mock('\Intervention\Image\Image');
|
||||
$canvas->shouldReceive('getCore')->times(2)->andReturn($resource);
|
||||
$canvas->shouldReceive('getCore')->times(5)->andReturn($resource);
|
||||
$canvas->shouldReceive('getSize')->andReturn($canvas_size);
|
||||
$driver = Mockery::mock('\Intervention\Image\Gd\Driver');
|
||||
$driver->shouldReceive('newImage')->with(820, 640, '#b53717')->once()->andReturn($canvas);
|
||||
|
Reference in New Issue
Block a user