1
0
mirror of https://github.com/Intervention/image.git synced 2025-08-27 23:59:50 +02:00

Added BlurModifiers

This commit is contained in:
Oliver Vogel
2021-10-29 18:10:42 +02:00
parent a149d87b33
commit e475b28f01
2 changed files with 64 additions and 0 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Intervention\Image\Drivers\Gd\Modifiers;
use Intervention\Image\Interfaces\FrameInterface;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
class BlurModifier implements ModifierInterface
{
/**
* Create new modifier
*
* @param int $amount Blur amount (0 - 100%)
*/
public function __construct(int $amount)
{
$this->amount = $amount;
}
public function apply(ImageInterface $image): ImageInterface
{
foreach ($image as $frame) {
$this->blurFrame($frame);
}
return $image;
}
protected function blurFrame(FrameInterface $frame): void
{
for ($i = 0; $i < $this->amount; $i++) {
imagefilter($frame->getCore(), IMG_FILTER_GAUSSIAN_BLUR);
}
}
}

View File

@@ -0,0 +1,28 @@
<?php
namespace Intervention\Image\Drivers\Imagick\Modifiers;
use Intervention\Image\Interfaces\ImageInterface;
use Intervention\Image\Interfaces\ModifierInterface;
class BlurModifier implements ModifierInterface
{
/**
* Create new modifier
*
* @param int $amount Blur amount (0 - 100%)
*/
public function __construct(int $amount)
{
$this->amount = $amount;
}
public function apply(ImageInterface $image): ImageInterface
{
foreach ($this->image as $frame) {
$frame->getCore()->blurImage(1 * $this->amount, 0.5 * $this->amount);
}
return $this->image;
}
}