Why are spaces forbidden in the -convolve argument

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
Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Why are spaces forbidden in the -convolve argument

Post by Jean-Pierre Coulon » 2018-06-21T04:38:15-07:00

magick -convolve 1,1,1,1,1,1,1,1,1 works well but fails if I say 1,1,1, 1,1,1, 1,1,1. This would help me to arrange my array when it is bigger e.g. 7x7.

Any workaround?

User avatar
fmw42
Posts: 25563
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Why are spaces forbidden in the -convolve argument

Post by fmw42 » 2018-06-21T09:02:56-07:00

Put quotes about your arguments and see if that works. With spaces, the arguments are considered as multiple sets of arguments and not one set.

Also consider using the newer -morphology convolve rather than the older legacy -convolve. See http://www.imagemagick.org/Usage/convolve/

snibgo
Posts: 12161
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Why are spaces forbidden in the -convolve argument

Post by snibgo » 2018-06-21T09:26:39-07:00

The shell (bash, or Windows CMD, or whatever) breaks the command line at spaces into arguments, passing each of those separately to the executable binary. But it treats a quoted string as a single arguments, even if it contains spaces.

For Windows, use double-quote: ".

For bash, use single-quote ' or double-quote ", according to your needs.
snibgo's IM pages: im.snibgo.com

Jean-Pierre Coulon
Posts: 41
Joined: 2016-10-04T02:08:22-07:00
Authentication code: 1151
Location: Nice, France

Re: Why are spaces forbidden in the -convolve argument

Post by Jean-Pierre Coulon » 2018-06-22T00:22:01-07:00

With Windows I obtain what I want with
magick chunk.png -convolve ^
0,0,3,4,3,0,0,^
3,4,4,4,4,4,3,^ etc.

User avatar
fmw42
Posts: 25563
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Why are spaces forbidden in the -convolve argument

Post by fmw42 » 2018-06-22T08:58:52-07:00

Jean-Pierre Coulon wrote:
2018-06-22T00:22:01-07:00
With Windows I obtain what I want with
magick chunk.png -convolve ^
0,0,3,4,3,0,0,^
3,4,4,4,4,4,3,^ etc.
You have no spaces so it works fine. The issue was when the argument to -convolve has spaces, which require quoting.

Post Reply