Convolution.php in Image Effects 8.3
File
src/Plugin/ImageToolkit/Operation/imagemagick/Convolution.php
View source
<?php
namespace Drupal\image_effects\Plugin\ImageToolkit\Operation\imagemagick;
use Drupal\image_effects\Plugin\ImageToolkit\Operation\ConvolutionTrait;
use Drupal\imagemagick\Plugin\ImageToolkit\Operation\imagemagick\ImagemagickImageToolkitOperationBase;
class Convolution extends ImagemagickImageToolkitOperationBase {
use ConvolutionTrait;
protected function execute(array $arguments) {
if (isset($arguments['kernel']) && isset($arguments['divisor']) && isset($arguments['offset'])) {
$matrix_s = '';
foreach ($arguments['kernel'] as $vector) {
$vector = array_map(function ($e) use ($arguments) {
return $e / $arguments['divisor'] + $arguments['offset'];
}, $vector);
$matrix_s .= implode(',', $vector) . " ";
}
$matrix_s = substr($matrix_s, 0, -1);
$this
->addArgument("-morphology Convolve '3x3:{$matrix_s}'");
}
return TRUE;
}
}