Dynamic blur command

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
Videomajk
Posts: 14
Joined: 2017-02-18T07:46:04-07:00
Authentication code: 1151

Dynamic blur command

Post by Videomajk »

Hello

I'm trying to create a dynamic blur effect where the sigma value is dependent on other image value. I've tried this:

Code: Select all

-blur 0x%%[fx:h/400]
I understand from other posts that this is not supported by the blurr command. Is there Another way of achiving this effect?
My IM version is 6.9.7 on Win10.
------------------------------------------------------------------------
Imagemagick v 7.0.4 | Windows 10
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Dynamic blur command

Post by snibgo »

The magick you need is "-compose blur".

See http://www.imagemagick.org/Usage/mapping/#blur and examples on my "Selective blur" page.
snibgo's IM pages: im.snibgo.com
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Dynamic blur command

Post by snibgo »

Correction to the above: I think I misunderstood what you want.

I now think you want a constant blur for a given image, a constant sigma, but that will depend on an expression, eg:

Code: Select all

magick toes.png -blur 0x%[fx:h/400] b.png
This works in v7, but is not available in v6.

For v6, you can first calculate the sigma as an environment variable:

Code: Select all

for /F "usebackq" %L in (`identify -format "SIG=%[fx:h/400]" toes.png`) do set %L

convert toes.png -blur 0x%SIG% b.png
If using BAT files, don't forget to double the % signs as required.
snibgo's IM pages: im.snibgo.com
Post Reply