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

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
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

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

Post 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)
Last edited by pipitas on 2018-03-21T11:44:58-07:00, edited 1 time in total.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

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

Post 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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post 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.
pipitas
Posts: 168
Joined: 2012-07-15T14:06:46-07:00
Authentication code: 15

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

Post 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....
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

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

Post by fmw42 »

see http://imagemagick.org/script/porting.php#cli

That is the only doc that I know about.
Post Reply