Hey guys,

it would be really great if you add a blur action.

So that my images can look like the attachment.

Thanks

Comments

dman’s picture

Shouldn't be too hard to add. GD allows for two options

  imagefilter($image, IMG_FILTER_GAUSSIAN_BLUR);
  imagefilter($image, IMG_FILTER_SELECTIVE_BLUR);

... however they take no arguments, so the amount of blur is a constant AFAIK. This means it probably will NOT blur as much as your example there. Maybe a repeated loop would do that though.

I'm sure there is something similar for imagemagick.
Just not seen the need for it yet...

CoPut’s picture

And while this feature doesn't realized as separate Imagecache Action we can use custom action with following code:

for ($i=0; $i<=40; $i++) imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
return $image;

Thank you for a clue, dman!

parasox’s picture

Version: » 7.x-1.x-dev

I tried this code (d7 dev version) and it doesn't work for me. Gives me an error and I have to delete the imagecache style.

Is it incomplete perhaps? Is this not all I have to paste into the custom action box? I don't really code, not sure.

I tried with both GD and ImageMagick selected as my toolkit.

Very much interested in being able to blur images

jthomasbailey’s picture

A good way of doing it is to just scale down the image and then scale it back up.

luksak’s picture

Got the same issue as #3. This is not caused by the blur you are trying to add. It is the custom action itself which has got a bug:

Recoverable fatal error: Argument 4 passed to db_query_range() must be an array, integer given, called in /sites/all/modules/imagecache_actions/utility.inc on line 273 and defined in db_query_range() (line 2341 of 
/includes/database/database.inc).

@hobgobbler:
Haha, are you serious?

luksak’s picture

Category: feature » bug
jthomasbailey’s picture

@ Lukas yeah, that's what I'm doing and it looks pretty good!

luksak’s picture

Well, my images get pixeled... I solved this with JS.

yannickoo’s picture

With JS? How?

luksak’s picture

Basically I convert an image to a canvas and then blur it. Pixsastic does this.

fietserwin’s picture

Category: bug » feature

The bug could not be found by me, I could not even find a db_query_range() in the module code.

So, back to the original feature request: blur effect.

dman’s picture

thanks for the work you are doing in the queue fietserwin :-)

fietserwin’s picture

Status: Active » Postponed

Postponing for now until we have a 7.x-1.0 release out.

Please feel free to post patches/code if you have so. I will be glad to add it.

hartogsmith’s picture

in case anyone else is still trying, this works in D7 as a custom action:

$amount = 2; // blur intensity
for ($i = 0; $i < $amount; $i++) {
  imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
}
return imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
Anonymous’s picture

#14 worked perfectly for me. I bumped up the blur intensity to 10, which was needed for the large images on this project.

Thanks for the snippet!

Anne

Anonymous’s picture

Issue summary: View changes

Removed name.

dman’s picture

Issue summary: View changes
Status: Postponed » Closed (won't fix)

https://www.drupal.org/project/filtersie advertises this without code. Go for that.
Closing this issue unless there is further interest.

GrantI’s picture

#14 worked for me perfectly. I suggest this method over the other 'none code' modules. I tried several and had no luck, this worked perfectly!

dman’s picture

#14 worked for me too, and interestingly I had need to find and recycle this answer again myself, just this week.

I don't like having to introduce PHP custom code through the UI if it can be helped ... but yeah, it it a pretty simple and useful fix.

idebr’s picture

Status: Closed (won't fix) » Needs review
StatusFileSize
new3.45 KB

Considering the success of the implementation of #14, I have created a patch that implements the blur effect in the Imagecache Canvas Actions module. This implementation is more straightforward than the FiltersIE module mentioned in #16, since you don't have to implement your own convolution matrix. The only configuration option is the amount of times the Gaussian blur is applied to the image.

@dman/@fietserwin I am not sure if every effect is mentioned in the module description, so I'll leave that part up to you. Thanks for your time in maintaining this project!

deanflory’s picture

Thanks idebr for the excellent blur effect. Much appreciated and needed! I've also considered it might be useful along with dynamic_background to create a "blur up" effect on background images: #2646948: Blur Up tiny blurred loading image that fades to large detailed image when loaded

deanflory’s picture

I've had success when using the #19 patch so I'd give it a rtbc, though I have not scoured the code to see if there are any downsides (it works, sooo...). Setting as Reviewed & Tested by the Community and see no reason why this shouldn't be included.

deanflory’s picture

Status: Needs review » Reviewed & tested by the community
fietserwin’s picture

  1. +++ b/canvasactions/canvasactions.inc
    @@ -1066,3 +1066,56 @@ function canvasactions_resizepercent_dimensions(array &$dimensions, array $data)
    +    '#default_value' => isset($data['intensity']) ? (float) $data['intensity'] : 2,
    

    (int) instead of (float)

  2. +++ b/canvasactions/canvasactions.inc
    @@ -1066,3 +1066,56 @@ function canvasactions_resizepercent_dimensions(array &$dimensions, array $data)
    +function canvasactions_blur_effect(stdClass $image, array $data) {
    

    - Should be called indirectly via image_toolkit_invoke.
    - Imagemagick support is simple to add for blur [though the parameter may get a different meaning :(]:

      $image->ops[] = '-blur ' . escapeshellarg("0x$sigma");
      return TRUE;
    
  3. +++ b/canvasactions/canvasactions.inc
    @@ -1066,3 +1066,56 @@ function canvasactions_resizepercent_dimensions(array &$dimensions, array $data)
    +  for ($i = 0; $i < $amount; $i++) {
    +    imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
    +  }
    +  return imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
    

    - why execute the filter amount + 1 times? That's not what the description tells.
    - why not in 1 loop, because we only want to check the result of the last invocation? check all calls and exit on 1st error.

    $result = TRUE;
    $i = 0;
    while ($result && $i++ < $intensity) {
     $result = imagefilter($image->resource, IMG_FILTER_GAUSSIAN_BLUR);
    }
    return $result;
    

    - why the GAUSSIAN blur and not the SELECTIVE blur? Did you test both? What are the differences?

    NB: http://www.imagemagick.org/Usage/blur/ tells me to better always use the standard blur in IM (not sure if that is the selective blur).

I will make the changes and credit @idebr in the commit message as well.

fietserwin’s picture

Issue summary: View changes
StatusFileSize
new62.91 KB
new63.63 KB
new64.12 KB
new82.26 KB
new77.47 KB
new48.36 KB
new58.19 KB

I did some tests. Results so far:

- The selective filter is not going to work,so we stay with the Gaussian filter:

- We could say that the value to pass to Im should be 1/10th of the value passed to GD (50 vs 5):

- But for low values the IM blurring is less than for GD (10 vs 1):

- And for higher values the IM blurring is too much (100 vs 10):

So I guess that for IM I'm going to correct with a smaller multiplication factor but with an offset, something like 5 + 8/10*intensity (in IM the sigma may be a float anyway....)

fietserwin’s picture

Component: Custom Actions Module » Canvas Actions Module
Status: Reviewed & tested by the community » Fixed

I went for 4 + 0.8 * $intensity ...

Committed, thanks for contributing,and if you are interested in doing some porting to D8: you are welcome on the successor of this module: https://www.drupal.org/project/image_effects.

@idebr: you want a link on our project page, was it your time, your company's time or your client's time?

idebr’s picture

@fietserwin Looks great, thanks! No need for a link on the project page, but thanks for the offer :)

fietserwin’s picture

OK, I just added a link to your Drupal user page.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

This is very useful. Any chance of a new release? It's been a while since 1.5.