diff --git a/src/Intervention/Image/Imagick/Commands/OpacityCommand.php b/src/Intervention/Image/Imagick/Commands/OpacityCommand.php index 994cd1b5..a498e1a5 100644 --- a/src/Intervention/Image/Imagick/Commands/OpacityCommand.php +++ b/src/Intervention/Image/Imagick/Commands/OpacityCommand.php @@ -13,7 +13,9 @@ class OpacityCommand extends \Intervention\Image\Commands\AbstractCommand public function execute($image) { $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); } } diff --git a/tests/GdSystemTest.php b/tests/GdSystemTest.php index 5fb709b7..2560d4ef 100644 --- a/tests/GdSystemTest.php +++ b/tests/GdSystemTest.php @@ -827,6 +827,7 @@ class GdSystemTest extends PHPUnit_Framework_TestCase $this->assertEquals($checkColor[1], 81); $this->assertEquals($checkColor[2], 96); $this->assertEquals($checkColor[3], 0.5); + $this->assertTransparentPosition($img, 0, 11); } public function testMaskImage() diff --git a/tests/ImagickSystemTest.php b/tests/ImagickSystemTest.php index af686ceb..d782e15d 100644 --- a/tests/ImagickSystemTest.php +++ b/tests/ImagickSystemTest.php @@ -828,6 +828,7 @@ class ImagickSystemTest extends PHPUnit_Framework_TestCase $this->assertEquals($checkColor[1], 81); $this->assertEquals($checkColor[2], 96); $this->assertEquals($checkColor[3], 0.5); + $this->assertTransparentPosition($img, 0, 11); } public function testMaskImage() diff --git a/tests/OpacityCommandTest.php b/tests/OpacityCommandTest.php index c1d7153e..9fdf7a98 100644 --- a/tests/OpacityCommandTest.php +++ b/tests/OpacityCommandTest.php @@ -33,7 +33,7 @@ class OpacityCommandTest extends PHPUnit_Framework_TestCase public function testImagick() { $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->shouldReceive('getCore')->once()->andReturn($imagick); $command = new OpacityImagick(array(50));