1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-30 17:19:50 +02:00

fixed bug images losing colorspace when using resizeCanvas

This commit is contained in:
Oliver Vogel
2014-12-20 15:14:38 +01:00
parent 9271c37cec
commit b5350f62f5
2 changed files with 6 additions and 2 deletions

View File

@@ -74,6 +74,8 @@ class ResizeCanvasCommand extends \Intervention\Image\Commands\AbstractCommand
$canvas->getCore()->drawImage($rect);
$canvas->getCore()->transparentPaintImage($fill, 0, 0, false);
$canvas->getCore()->setImageColorspace($image->getCore()->getImageColorspace());
// copy image into new canvas
$image->getCore()->cropImage($src_w, $src_h, $src_x, $src_y);
$canvas->getCore()->compositeImage($image->getCore(), \Imagick::COMPOSITE_DEFAULT, $dst_x, $dst_y);

View File

@@ -56,8 +56,10 @@ class ResizeCanvasCommandTest extends PHPUnit_Framework_TestCase
$imagick->shouldReceive('setimagepage')->with(0, 0, 0, 0)->once();
$imagick->shouldReceive('drawimage')->once();
$imagick->shouldReceive('transparentpaintimage')->once();
$imagick->shouldReceive('getimagecolorspace')->once();
$imagick->shouldReceive('setimagecolorspace')->once();
$canvas->shouldReceive('getCore')->times(5)->andReturn($imagick);
$canvas->shouldReceive('getCore')->times(6)->andReturn($imagick);
$canvas->shouldReceive('getSize')->andReturn($canvas_size);
$canvas->shouldReceive('pickColor')->with(0, 0, 'hex')->once()->andReturn('#000000');
$driver = Mockery::mock('\Intervention\Image\Gd\Driver');
@@ -67,7 +69,7 @@ class ResizeCanvasCommandTest extends PHPUnit_Framework_TestCase
$image->shouldReceive('getSize')->once()->andReturn($image_size);
$image->shouldReceive('getWidth')->once()->andReturn(800);
$image->shouldReceive('getHeight')->once()->andReturn(600);
$image->shouldReceive('getCore')->times(2)->andReturn($imagick);
$image->shouldReceive('getCore')->times(3)->andReturn($imagick);
$image->shouldReceive('setCore')->once();
$command = new ResizeCanvasImagick(array(20, 40, 'center', true, '#b53717'));
$result = $command->execute($image);