Page 1 of 4

Typos in the command line option page for V 6

Posted: 2016-01-04T19:44:25-07:00
by ronsavage
I'm referring to this page: http://imagemagick.org/script/command-line-options.php:

Several items have a '}}' rather than a '}' at the end, or perhaps are missing a '{' somewhere:

-brightness-contrast brightness{xcontrast}{%}}

-contrast-stretch black-point{xwhite-point}{%}}

-linear-stretch black-point{xwhite-point}{%}}

-mean-shift widthxheight{+distance{%}}

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T19:54:02-07:00
by fmw42
The extra braces are for optional arguments.

But I would agree that they are unbalanced as

Code: Select all

-contrast-stretch black-point{xwhite-point}{%}}
should most likely be

Code: Select all

-contrast-stretch black-point{xwhite-point}{%}
but could be

Code: Select all

-contrast-stretch black-point{{xwhite-point{%}}

But I would leave the decision to remove or add a brace to the IM developers.

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T20:14:27-07:00
by ronsavage
OK.

When you say 'optional arguments', what's the difference between using [xyz] and {xyz}?

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T20:18:01-07:00
by fmw42
The braces are not used. They are there in the documentation just to show what arguments are optional.

For example:

Code: Select all

-contrast-stretch black-point

-contrast-stretch black-pointxwhite-point

-contrast-stretch black-pointxwhite-point%

-contrast-stretch black-pointxwhite-point%

-contrast-stretch black-point%xwhite-point%
IM will use both as percent even if it see only one percent.

The "x" separates the two arguments. Often it can be replace with ","

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T20:22:34-07:00
by fmw42
Parentheses are (...)
Brackets are [...]
Braces are {...}

It seems that the documentation is inconsistent in the use of brackets and braces to both mean optional arguments. I am not sure when the braces were intruduced. It used to be always brackets.

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T20:52:53-07:00
by ronsavage
Ahhh. I got auto-logged-off, and lost my long reply. Not happy.

Thanx for the clarification. I agree it's inconsistent, and I'd say regrettable.

And I do understand '[]' and '{}' do not actually appear on the command line.

The reason I'm studying this page is that I'm writing a Perl module which parses IM command lines.

Although this might seem pointless, it's to build a data structure that other Perl modules, e.g. Imager, can use to provide some support, however limited, for users who prototype using 'convert'. More here: https://rt.cpan.org/Ticket/Display.html?id=91883.

So, I've written code which parses that doc page, and outputs the corresponding BNF for use by Marpa::R2. It's not finished of course. Will it work? I hope so.

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T21:00:51-07:00
by fmw42
I believe that the documentation will be fixed on this issue. The IM developer will do that or he can direct me to do it.

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T21:02:52-07:00
by ronsavage
Great news!

Re: Typos in the command line option page for V 6

Posted: 2016-01-04T21:36:42-07:00
by ronsavage
Also, probably a good time to unify 'index(s)' and 'indexes'.

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T14:03:09-07:00
by ronsavage
Also, I think {+-} generally means we must make a mandatory choice of either '+' or '-', whereas with a case like '-bias value{%}' (and if not that option, then elsewhere), the intention is that '%' is optional.

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T14:09:59-07:00
by ronsavage
And, for '-rotate degrees{<}{>}', should that read [<>], meaning choose only one, or neither?

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T14:11:12-07:00
by ronsavage
And likewise for '-delay ticksxticks-per-second {<} {>}'?

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T16:08:55-07:00
by snibgo
IM's language has gradually evolved over the years, and isn't easily defined in BNF. (But good luck with it!) Some aspects are rather vague, and IM will accept syntax that it shouldn't.

With "-rotate", IM v6 currently accepts < or > or both (in either order) or neither. Using both is somewhat pointless and seems to give the expected result: the image is never rotated.

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T16:15:16-07:00
by ronsavage
That's good to know, even if it increases my confusion level :-).

I do have a number of other observations, which I'll relate shortly.

Re: Typos in the command line option page for V 6

Posted: 2016-01-05T16:52:01-07:00
by fmw42
ronsavage wrote:Also, I think {+-} generally means we must make a mandatory choice of either '+' or '-', whereas with a case like '-bias value{%}' (and if not that option, then elsewhere), the intention is that '%' is optional.
That is correct as far as I know.