Page 1 of 1

Cannot get "-set option:wizsize '%wx%h'" to work

Posted: 2018-03-21T11:04:31-07:00
by pipitas
In the IM documentation about the '-set'/'+set' command line options (here: https://www.imagemagick.org/script/comm ... ns.php#set) we can find this example:

Code: Select all

magick convert rose:           \
  -set option:rosesize '%wx%h' \
  -delete 0                    \
  label:'%[rosesize]'          \
  label_size_of_rose.gif

This works as expected and shows like this: Image
Now I wanted to create in an analog way a blue 'xc:' canvas using the size of 'wizard:'

Code: Select all

magick convert wizard:        \
  -set option:wizsize '%wx%h' \
  -delete 0                   \
  -size '%[wizsize]'          \
  xc:blue                     \
  blue.png
However, this only triggers an error message:

Code: Select all

convert: invalid argument for option '-size': %[wizsize] @ error/convert.c/ConvertImageCommand/2809.
What do I miss? Anything I'm doing wrong here?

I tested with the following two versions (both self-compiled from Git sources at various recent points in time):

Code: Select all

ImageMagick 7.0.7-28 Q16 x86_64 20180318 http://www.imagemagick.org     ( <== on Debian Linux)
ImageMagick 7.0.7-26 Q16 x86_64 20180304 http://www.imagemagick.org     ( <== on Debian Linux)
ImageMagick 7.0.7-15 Q16 x86_64 2017-12-09 http://www.imagemagick.org   ( <== on macOS)

Re: Cannot get "-set option:wizsize '%wx%h'" to work

Posted: 2018-03-21T11:44:27-07:00
by pipitas
I may add the following info. Running this command:

Code: Select all

magick convert wizard:        \
  -set option:wizsize '%wx%h' \
  -print "%[wizsize]\n"       \
  null:
works as expected and prints:

Code: Select all

480x640

Re: Cannot get "-set option:wizsize '%wx%h'" to work

Posted: 2018-03-21T12:34:05-07:00
by fmw42
Your problem is that you have included convert (as magick convert). That runs IM 6 convert from IM 7. IM 6 does not allow inline computations from -set option to be used in -size. Remove the convert so that you have only magick and it should work:

Code: Select all

magick wizard:  \
-set option:wizsize '%wx%h' \
-delete 0                   \
-size '%[wizsize]'          \
xc:blue                     \
blue.png
This works fine for me on IM 7.0.7.27 Q16 Mac OSX Sierra for me.

Note that label: already permitted -set options in IM 6, so that is why it worked. But -size did not do that until IM 7.

Re: Cannot get "-set option:wizsize '%wx%h'" to work

Posted: 2018-03-21T12:54:23-07:00
by pipitas
Oohhhhhh.... Thanks a bunch, Fred!

In this case, all this time since IM7 is out, I didn't really grok the fine differences of running 'magick ...' and 'magick convert ...' !
I'll have to dig deeper into the docu then. Any hints with direct links? Otherwise, I'll dig myself....

Re: Cannot get "-set option:wizsize '%wx%h'" to work

Posted: 2018-03-21T13:03:29-07:00
by fmw42
see http://imagemagick.org/script/porting.php#cli

That is the only doc that I know about.