1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-25 23:06:13 +02:00

fixed issue with opacity() not retaining transparency with Imagick

This commit is contained in:
Oliver Vogel
2014-05-21 20:33:11 +02:00
parent 9b883f3548
commit 3b202292db
4 changed files with 6 additions and 2 deletions

View File

@@ -13,7 +13,9 @@ class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand
public function execute($image) public function execute($image)
{ {
$transparency = $this->argument(0)->between(0, 100)->required()->value(); $transparency = $this->argument(0)->between(0, 100)->required()->value();
$transparency = $transparency > 0 ? (100 / $transparency) : 1000;
return $image->getCore()->setImageOpacity($transparency / 100); return $image->getCore()->evaluateImage(\Imagick::EVALUATE_DIVIDE, $transparency, \Imagick::CHANNEL_ALPHA);
} }
} }

View File

@@ -827,6 +827,7 @@ class GdSystemTest extends PHPUnit_Framework_TestCase
$this->assertEquals($checkColor[1], 81); $this->assertEquals($checkColor[1], 81);
$this->assertEquals($checkColor[2], 96); $this->assertEquals($checkColor[2], 96);
$this->assertEquals($checkColor[3], 0.5); $this->assertEquals($checkColor[3], 0.5);
$this->assertTransparentPosition($img, 0, 11);
} }
public function testMaskImage() public function testMaskImage()

View File

@@ -828,6 +828,7 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase
$this->assertEquals($checkColor[1], 81); $this->assertEquals($checkColor[1], 81);
$this->assertEquals($checkColor[2], 96); $this->assertEquals($checkColor[2], 96);
$this->assertEquals($checkColor[3], 0.5); $this->assertEquals($checkColor[3], 0.5);
$this->assertTransparentPosition($img, 0, 11);
} }
public function testMaskImage() public function testMaskImage()

View File

@@ -33,7 +33,7 @@ class OpacityCommandTest extends PHPUnit_Framework_TestCase
public function testImagick() public function testImagick()
{ {
$imagick = Mockery::mock('Imagick'); $imagick = Mockery::mock('Imagick');
$imagick->shouldReceive('setimageopacity')->with(0.5)->andReturn(true); $imagick->shouldReceive('evaluateimage')->with(\Imagick::EVALUATE_DIVIDE, 2, \Imagick::CHANNEL_ALPHA)->andReturn(true);
$image = Mockery::mock('Intervention\Image\Image'); $image = Mockery::mock('Intervention\Image\Image');
$image->shouldReceive('getCore')->once()->andReturn($imagick); $image->shouldReceive('getCore')->once()->andReturn($imagick);
$command = new OpacityImagick(array(50)); $command = new OpacityImagick(array(50));