possible bug IM 7.0.9.2 -set option:distort:viewport not centering properly

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

possible bug IM 7.0.9.2 -set option:distort:viewport not centering properly

Post by fmw42 »

IM 7.0.9.2 -set option:distort:viewport is not centering properly. The barn image is not centering horizontally properly. See below. Note it works fine in IM 6.9.10.71

Input Images:

Image

Image

Image


Does not center barn image in IM 7:

Code: Select all

magick lena.jpg barn.jpg monet2.jpg -virtual-pixel white -set option:distort:viewport "592x842-%[fx:(592-u[t].w)/2]-%[fx:(842-u[t].h)/2]" -distort SRT 0 result7.png
Image

Image

Image


Works fine in IM 6:

Image

Image

Image

User avatar
GeeMack
Posts: 757
Joined: 2015-12-01T22:09:46-07:00
Authentication code: 1151
Location: Central Illinois, USA

Re: possible bug IM 7.0.9.2 -set option:distort:viewport not centering properly

Post by GeeMack »

I get the same incorrect result using ImageMagick 7.0.9-3 Q16 x64 HDRI on Windows 10.

It also generates the same incorrect result when using "s.w" and "s.h" instead of "u[t].w" and "u[t].h".

User avatar
magick
Site Admin
Posts: 11254
Joined: 2003-05-31T11:32:55-07:00

Re: possible bug IM 7.0.9.2 -set option:distort:viewport not centering properly

Post by magick »

The legacy ImageMagick 6 parser has delayed interpretation of the Fx expression whereas the ImageMagick 7 parser has immediate effect. You have two options, use the legacy parser (e.g. magick convert ...) or force immediate Fx interpretation with this command:

Code: Select all

magick  \
  \( lena.jpg -set option:distort:viewport "592x842-%[fx:(592-u[t].w)/2]-%[fx:(842-u[t].h)/2]" \) \
  \( barn.jpg -set option:distort:viewport "592x842-%[fx:(592-u[t].w)/2]-%[fx:(842-u[t].h)/2]" \) \
  \( monet2.jpg -set option:distort:viewport "592x842-%[fx:(592-u[t].w)/2]-%[fx:(842-u[t].h)/2]" \) \
  -virtual-pixel white -distort SRT 0 result7.png
See https://imagemagick.org/script/porting.php:

As mentioned the primary focus of the changes to the Shell API or Command Line Interface is the abstraction so that not only can options be read from command line arguments, but also from a file (script) or from a file stream (interactive commands, or co-processing).

To do this the CLI parser needed to be re-written, so as to always perform all options, in a strict, do-it-as-you-see it order.

Locked