A great module for Drupal 7 is the filtersie module which add a few sharpen filters. Instead of adding a Drupal 8 issue over there I decided to ask the question here instead to promote consolidation of image effects available to Drupal 8. Is this something which could be easily ported?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vaccinemedia created an issue. See original summary.

slashrsm’s picture

Issue tags: +Media Initiative, +D8Media

It seems pretty straightforward. We should try to get approval from filtersie's maintainer.

drikc’s picture

Filtersie use 2 different sharpening implementations:
1. "unsharp mask" which use the code here http://vikjavev.no/computing/ump.php
2. convolution with a predefined kernel that use concrete execution of either gd or imagemagick

So, I'm not the author of any of the concrete implementation; only integration in the drupal image effect. So anyone must feel free to use those...

That said, filtersie is toward filters image effect using convolution... I'll probably do a d8x in the future. Or perhaps it may be integrated into image_effects...

drikc’s picture

Status: Active » Needs review
FileSize
10.61 KB

This patch implements convolution (as in filtersie) which allows to setup a multitude of filters like blur, emboss, sharpen, etc... See http://docs.gimp.org/en/plug-in-convmatrix.html.

Todos:
- Include a predefined sharpen filter using convolution
- Include the "unsharp mask" sharpen technique: http://vikjavev.no/computing/ump.php
- Implements tests

mondrake’s picture

Status: Needs review » Needs work

Code looks good, setting to NW for todos in #4, plus:

  1. I would suggest a separate library entry for the css and js needed specifically for this effect's config form, rather than adding to admin.ui (that is relevant to multiple effects)
  2. +++ b/css/image_effects.admin.ui.css
    @@ -5,3 +5,7 @@ span.image-effects-color-box {
    +.form-item-data-kernel .kernel-entry {
    +  display: inline;
    +}
    

    can the classes/selectors also be made specific for this effect? Unless we believe that other effects could reuse.

  3. Is an ImageMagick implementation possible?
  4. Please add an entry to the README.md to list the effects - since the README.md is shown on GitHub this has the benefit of immediately updating the inventory of effects available. See other effect implementations issues for examples.
drikc’s picture

Status: Needs work » Needs review
FileSize
21.03 KB

This patch:
1. Implements tests for the convolution.
Tests if parameters are correctly passed to the toolkit; operation testing requires more work... Might be sufficient at the moment, also considering that operations are probably tested upstream at respective toolkit library.

2. Predefined sharpen filter
That is, using convolution

2. Convolution separate library
Dedicated css and js files

3. Imagemagick convolution (and predefined sharpen convolution)
Implemented but not tested at all...

4. README.md
Add an entry for convolution

Remaining todos:
Include the "unsharp mask" sharpen technique: http://vikjavev.no/computing/ump.php

drikc’s picture

Forgot README.md entry for the sharpen effect.

mondrake’s picture

Title: Add a sharpen preset(s) » Add "Convolution" and "Sharpen" image effects
Status: Needs review » Needs work

I tested manually the ImageMagick implementation and it all works fine AFAICS. Nice job!

To me this is pretty much ready to go.

@drikc:

Remaining todos:
Include the "unsharp mask" sharpen technique

do you want to do that still here, or can we commit this and do the rest in another issue?

Some minor things:

  1. +++ b/README.md
    @@ -34,6 +34,8 @@ Set canvas       | Places the source image over a colored or a transparent backg
     Watermark        | Place a image with transparency anywhere over a source picture.                              | X          | X                   |
    +Convolution      | Allows to build custom image filters like blur, emboss, sharpen and others (see http://docs.gimp.org/en/plug-in-convmatrix.html). | X          | X                   |
    +Sharpen          | Sharpens an image (using convolution).                                                          | X          | X                   |
     
     Image Effects tries to support both the GD toolkit from Drupal core and the
    

    Please add effects retaining the alphabetical order.

  2. +++ b/image_effects.libraries.yml
    @@ -23,3 +23,11 @@ image_effects.html_color_selector:
    +  css:
    +    component:
    +      css/image_effects.admin.convolution.css: {}
    \ No newline at end of file
    diff --git a/image_effects.module b/image_effects.module
    

    No blank line at end of file

  3. +++ b/src/Tests/ImageEffectsConvolutionTest.php
    @@ -0,0 +1,94 @@
    +  /**
    +   * Test the image_resize_effect() function.
    +   */
    

    This is wrong

  4. +++ b/src/Tests/ImageEffectsConvolutionTest.php
    @@ -0,0 +1,94 @@
    +  /**
    +   * Test the image_resize_effect() function.
    +   */
    

    ... and this too

Please add interdiffs in new patches :) It helps reviewing

drikc’s picture

Status: Needs work » Needs review
FileSize
21.75 KB
3.05 KB

Ok, I will do the "unsharp mask" in an other issue.

Here's the update patch.

  • mondrake committed 700dd28 on 8.x-1.x authored by drikc
    Issue #2658364 by drikc: Add "Convolution" and "Sharpen" image effects
    
mondrake’s picture

Status: Needs review » Fixed

Great! Committed. Thank you @drikc

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.