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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post by glennrp »

This should produce a 100x30 image but the result is 30x30

Code: Select all

magick xc:[100x30] show:
Last edited by glennrp on 2016-11-13T18:55:11-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: W is ignored in xc:[WxH]

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: W is ignored in xc:[WxH]

Post by glennrp »

[blush]
Version: ImageMagick 7.0.3-3 Q16 x86_64
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: W is ignored in xc:[WxH]

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

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

Post 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.
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

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

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: W is ignored in xc:[WxH]

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

Re: W is ignored in xc:[WxH]

Post 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
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: W is ignored in xc:[WxH]

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

Re: W is ignored in xc:[WxH]

Post 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.
User avatar
glennrp
Posts: 1147
Joined: 2006-04-01T08:16:32-07:00
Location: Maryland 39.26.30N 76.16.01W

Re: W is ignored in xc:[WxH]

Post 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>
Post Reply