Using "-distort Resize" with FX substitutions...

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

Using "-distort Resize" with FX substitutions...

Post by GeeMack »

Running ImageMagick-6.9.6-0-Q16-HDRI-x64-static on Windows 10 64, it appears there's a problem using FX expression substitutions in a "-distort Resize" operation. Both of these commands should resize the gradient to 240x120 pixels...

Code: Select all

convert -size 480x240 gradient: -distort Resize %[h]x testing.png

Code: Select all

convert -size 480x240 gradient: -distort Resize %[fx:w/2]x testing.png
Instead they both run without warnings or errors, but they produce output images which are still 480x240. IM6 doesn't seem to have any trouble using FX expressions and substitutions with other "-distort" methods like "Affine". Is there a reason it shouldn't work with "-distort Resize", or is this maybe a bug?
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using "-distort Resize" with FX substitutions...

Post by snibgo »

I wasn't aware that FX expressions are supposed to work with "-distort Resize" on v6.
snibgo's IM pages: im.snibgo.com
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Using "-distort Resize" with FX substitutions...

Post by GeeMack »

snibgo wrote:I wasn't aware that FX expressions are supposed to work with "-distort Resize" on v6.
While it may be that FX escapes aren't meant to work with "-distort Resize", the documentation mentions HERE that "You can also use Percent Escapes within the distort arguments," and provides an example using "-distort Affine". I've tried the example in various ways with simple escapes and with expressions like "%[fx:w*2]", and it seems to work as expected.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Using "-distort Resize" with FX substitutions...

Post by snibgo »

Historically, I think "-distort resize" was added after the other distorts, as a drop-in replacement for "-resize", so had to parse and process its arguments in the same way.

For v6, in wand\mogrify.c, function MogrifyImage(), after "-distort" is found, the "resize" method is treated differently to all other methods. "resize" uses ParseRegionGeometry(), but all other methods use InterpretImageProperties(), and this is what translates %[stuff].
snibgo's IM pages: im.snibgo.com
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Using "-distort Resize" with FX substitutions...

Post by fmw42 »

It does not work for me in IM 6.9.6.0 Q16 Mac OSX. But does work with IM 7.0.3.2 Q16.

Code: Select all

magick -size 480x240 gradient: -distort Resize "%[fx:w/2]" testing.png
User avatar
GeeMack
Posts: 718
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: Using "-distort Resize" with FX substitutions...

Post by GeeMack »

snibgo wrote:Historically, I think "-distort resize" was added after the other distorts, as a drop-in replacement for "-resize", so had to parse and process its arguments in the same way.
That makes sense. I use IM7 for almost everything, but I keep a recent IM6 installed so I can test stuff, mostly for questions on this forum. I didn't know if FX escape and expression processing was part of "-distort" or part of each method.
Post Reply