Hi,
could I have your opinion about this bug [1]
Reproduced here
How to reproduce:
$ mkdir -p /tmp/a ; cd /tmp/a
$ for f in alpha beta -delta; do convert -size 100x100 xc: +noise Random -- $f.png; done
$ montage -- *.png gamma.jpg
Expected behaviour:
( image gamma.jpg is created )
Observed behaviour:
"montage: unrecognized option `-delta.png' @ error/montage.c/MontageImageCommand/865."
What's weird is I'd expect convert to throw a similar exception when I execute:
$ convert -size 100x100 xc: +noise Random -delta.png
but it doesn't. This is what I get instead when I use '--' to stop parsing switches:
$ convert -size 100x100 xc: +noise Random -- -delta.png
convert: missing an image filename `-delta.png' @ error/convert.c/ConvertImageCommand/3009.
[1] https://bugs.launchpad.net/ubuntu/+sour ... ug/1050950
-- and command parsing
Re: -- and command parsing
We don't support file names that start with a dash. A dash is interpreted as an option other than the last option of the convert command which is assumed to be a filename. We also do not support the dash-dash sentinal. ImageMagick v7 returns an exception if the last command line argument begins with a dash. Its possible Anthony will support a dash prefix for filenames in ImageMagick v7, although currently it does not appear to be supported.
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: -- and command parsing
The -- is not doing what you expect, and while defined in IMv6 it is not really supported.
It is meant to be equivalent to a explicit 'read operator' (which in IMv7 will be available as "-read")
As opposed to a implicit read for any argument that is ...ahem... not an option.
You wrote...
The shell expands the '*.png' into a list of filenames so Im sees something like...
This means ONLY the first file 'a.png' is seen by IMv6 as being an 'explicit read' the others are still 'implicit reads is not an option' Thus your "-dash.png" file will still be seen as an option!
Solution... stop the shell expanding the '*' and let IM do it, as part of the image read operation or
or more explictally
(not recommended)
IMv7 will have a "-read" operator. But will have the same problem as IMv6 '--' option with regards to shell expansion.
So you will need to get IM to do the glob file expression ('*') expansion.
However '--' will have different meaning in IMv7 (I not up to that point in development) so as to allow provided options to be grouped into 'stages.
One planned use of '--' is to add 'stages' or 'do your special processing here'. For example as we are talking about "montage" a '--' could seperate the image read stage from a new 'post processing stage' if a '--' is found in the argument....
Anything before the '--' is processed to read-in the images, then at the '--' the "montage" command will take those images and tile, lable, frame, shadow, and finally position and merged the images together into a paged grid layout.
After that the next set of user supplied options will be performed, so the montaged image is 'framed' before being saved into 'result.png'
As such I would not rely on '--', especially as it is not really needed.
The use of '--' will also be available in Magick Scripts Programs! That is script options will process up to '--' before the script continues with it normal handling.
You will then be able to write a scripts that can process given images, with extra user supplied processing steps at certain points! In fact 'montage' may simply become a magick script rather than a dedicated binary, once all its special image processing steps becomes available to the "magick" command (the "convert" command replacement). Specifically its 'grid layout' handler becomes available (along with out 'layout posibilities'). That means user could easily generate there own special 'montage'-like scripts
For more info on plans see
http://www.imagemagick.org/Usage/bugs/I ... ipting.txt
It is meant to be equivalent to a explicit 'read operator' (which in IMv7 will be available as "-read")
As opposed to a implicit read for any argument that is ...ahem... not an option.
You wrote...
Code: Select all
montage -- *.png gamma.jpg
Code: Select all
montage -- a.png b.png c.png d.png gamma.jpg
Solution... stop the shell expanding the '*' and let IM do it, as part of the image read operation
Code: Select all
montage '*.png' gamma.jpg
Code: Select all
montage 'png:*.png' gamma.jpg
Code: Select all
montage -- '*.png' gamma.jpg
IMv7 will have a "-read" operator. But will have the same problem as IMv6 '--' option with regards to shell expansion.
So you will need to get IM to do the glob file expression ('*') expansion.
Code: Select all
montage -read '*.png' gamma.jpg
One planned use of '--' is to add 'stages' or 'do your special processing here'. For example as we are talking about "montage" a '--' could seperate the image read stage from a new 'post processing stage' if a '--' is found in the argument....
Code: Select all
montage '*.png' -- -frame 10x10+3+3 result.png
After that the next set of user supplied options will be performed, so the montaged image is 'framed' before being saved into 'result.png'
As such I would not rely on '--', especially as it is not really needed.
The use of '--' will also be available in Magick Scripts Programs! That is script options will process up to '--' before the script continues with it normal handling.
You will then be able to write a scripts that can process given images, with extra user supplied processing steps at certain points! In fact 'montage' may simply become a magick script rather than a dedicated binary, once all its special image processing steps becomes available to the "magick" command (the "convert" command replacement). Specifically its 'grid layout' handler becomes available (along with out 'layout posibilities'). That means user could easily generate there own special 'montage'-like scripts
For more info on plans see
http://www.imagemagick.org/Usage/bugs/I ... ipting.txt
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: -- and command parsing
Does it help to use "./-delta.png" instead of "-delta.png" as the filename?
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: -- and command parsing
It certainly would Olli! It certainly would.
Update... Sorry I am showing my age... if you don't get the reference it was a common phrase from Laurel and Hardy.
Update... Sorry I am showing my age... if you don't get the reference it was a common phrase from Laurel and Hardy.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
-
- Posts: 467
- Joined: 2008-12-21T11:51:10-07:00
Re: -- and command parsing
Thanks for the precision