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 »

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: 25562
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 »

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: 12159
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 »

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 »

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: 25562
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 »

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