Page 1 of 1

[RESOLVED] W is ignored in xc:[WxH]

Posted: 2016-11-10T14:11:37-07:00
by glennrp
This should produce a 100x30 image but the result is 30x30

Code: Select all

magick xc:[100x30] show:

Re: W is ignored in xc:[WxH]

Posted: 2016-11-10T14:26:03-07:00
by fmw42
What is your IM version and platform?

On IM 6.9.6.4 Q16 (convert) and IM 7.0.3.6 Q16 (magick), I get the a 30x30 (white) image using:

Code: Select all

magick xc:[100x30] tmp.png
and also for

Code: Select all

magick xc:white[100x30] tmp.png

Re: W is ignored in xc:[WxH]

Posted: 2016-11-10T14:28:06-07:00
by glennrp
[blush]
Version: ImageMagick 7.0.3-3 Q16 x86_64

Re: W is ignored in xc:[WxH]

Posted: 2016-11-11T08:49:39-07:00
by GeeMack
glennrp wrote:This should produce a 100x30 image but the result is 30x30

Code: Select all

magick xc:[100x30] show:
Try this with an exclamation point "!"...

Code: Select all

magick xc:[100x30!] show:
The default "canvas:" or "xc:" is a 1x1 pixel square. The bang "!" will cause the command to ignore the 1:1 aspect and force the resize to the 100x30 dimensions.

[SOLVED] Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T07:28:05-07:00
by glennrp
Thanks, I forgot about the sequence of events (xc:color[WxH] doesn't directly generate a WxH image; instead it makes a 1x1 image then resizes it to WxH). So there's no bug here, just pilot error on my part.

I still get a puzzling result from xc:[W], though; that produces a 1x1 image instead of a WxW one. I think that's probably because the integer "W" is being interpreted as a scene number instead of as a geometry.

Re: [SOLVED] Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T10:44:57-07:00
by GeeMack
glennrp wrote:I still get a puzzling result from xc:[W], though; that produces a 1x1 image instead of a WxW one. I think that's probably because the integer "W" is being interpreted as a scene number instead of as a geometry.
Makes sense. If you put the "x" in there after the width, like "xc:[480x]", it should make the 480 pixel square canvas.

Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T13:24:29-07:00
by glennrp
Normally an extra "x" or "!" wouldn't matter, but I came across this problem while playing "Code Golf" at http://codegolf.stackexchange.com/quest ... 9087#99087 where every byte I use counts against me (similar to the actual game of golf where every whack at the ball counts against you).

Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T14:08:46-07:00
by fmw42
Out of curiosity

I tried xc:[40!], but that failed with an error "-bash: !]: event not found"

I tried xc:[40\!], but got a 40x1 result

Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T14:25:01-07:00
by glennrp
The bash csh-style history expansion with "!" only happens when you are typing in commands from a terminal window. In a bash script, a "!" is just a "!".

Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T14:38:25-07:00
by fmw42
But this works fine on my Mac OSX. No bash error for !

Code: Select all

convert rose: -resize 100x100! rose100.jpg
Difference here may be that the ! in 100x100! is the final character before a white space? Whereas in

convert xc:[40!] show:

the ! is not the last character before white space. Or perhaps it has to do with the bracket. I do not know enough to say.

Re: W is ignored in xc:[WxH]

Posted: 2016-11-12T15:50:34-07:00
by glennrp
Well, it isn't just peculiar to MacOS. I get the same on Ubuntu 16:04, when I type into the console:

Code: Select all

glenn.rp> magick convert xc:[40!] show:
bash: !]: event not found
glenn.rp>