public function ConvolutionSharpenImageEffect::applyEffect in Image Effects 8
Same name and namespace in other branches
- 8.3 src/Plugin/ImageEffect/ConvolutionSharpenImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\ConvolutionSharpenImageEffect::applyEffect()
- 8.2 src/Plugin/ImageEffect/ConvolutionSharpenImageEffect.php \Drupal\image_effects\Plugin\ImageEffect\ConvolutionSharpenImageEffect::applyEffect()
Applies an image effect to the image object.
Parameters
\Drupal\Core\Image\ImageInterface $image: An image file object.
Return value
bool TRUE on success. FALSE if unable to perform the image effect on the image.
Overrides ImageEffectInterface::applyEffect
File
- src/
Plugin/ ImageEffect/ ConvolutionSharpenImageEffect.php, line 67
Class
- ConvolutionSharpenImageEffect
- Sharpen image using convolution.
Namespace
Drupal\image_effects\Plugin\ImageEffectCode
public function applyEffect(ImageInterface $image) {
$sharpenlevel = $this->configuration['level'] / 100;
$kernel = [
[
-$sharpenlevel,
-$sharpenlevel,
-$sharpenlevel,
],
[
-$sharpenlevel,
8 * $sharpenlevel + 1,
-$sharpenlevel,
],
[
-$sharpenlevel,
-$sharpenlevel,
-$sharpenlevel,
],
];
return $image
->apply('convolution', [
'kernel' => $kernel,
'divisor' => 1,
'offset' => 0,
]);
}