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:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
@@ -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()
|
||||
|
@@ -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()
|
||||
|
@@ -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));
|
||||
|
Reference in New Issue
Block a user