1
0
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:
Oliver Vogel
2014-05-11 14:23:00 +02:00
parent c45c1d93b0
commit 28af54ac8b
2 changed files with 7 additions and 1 deletions

View File

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

View File

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