Page 1 of 1

Density escape values in FX expressions?

Posted: 2016-01-02T22:27:51-07:00
by GeeMack
Using ImageMagick 7.0.0-0 Q16 x64 2015-12-19 from the command line and batch files in Windows 7 Pro 64.

I'm building some scripts to make various labels to print with finished sizes and crop marks in inches and fractions. I'd like to calculate some dimensions in my IM7 commands using the resolution, or density values. These are available as IM escape characters "x" and "y" in the "identify -format..." command or when printing the density values in a "label:" or "-annotate" command. I'd like to use the density escapes in FX expressions, too.

As a simplified example, where this command works...

Code: Select all

magick -size 400x400 xc:blue -gravity center -extent %[fx:w+(72/2)]x%[fx:h+(72/2)] clipboard:
... a command like this fails...

Code: Select all

magick -size 400x400 xc:blue -gravity center -extent %[fx:w+(x/2)]x%[fx:h+(y/2)] clipboard:
It would be great if I could feed source images to some scripts without manually checking the resolutions and calculating those values. Is there any chance the %[x] and %[y] density escapes might be used in FX expressions in future releases of IM7?

Re: Density escape values in FX expressions?

Posted: 2016-01-02T22:34:47-07:00
by fmw42
see http://www.imagemagick.org/script/fx.php

try using resolution.x and resolution.y rather than x and y

Re: Density escape values in FX expressions?

Posted: 2016-01-02T22:54:28-07:00
by GeeMack
fmw42 wrote:try using resolution.x and resolution.y rather than x and y
I was looking at that page earlier and apparently was thinking I'd find what I wanted in the single letter symbols. Yep, I overlooked the perfect answer just a few lines later. That does exactly what I was looking for. Thanks much for your speedy reply!

Re: Density escape values in FX expressions?

Posted: 2016-01-02T23:11:40-07:00
by fmw42
I do not believe that all string formats listed at http://www.imagemagick.org/script/escape.php can be used directly in fx escape computations. For many you will have to get the string format and put it into a variable first. Then use the variable in the fx escape calculation. At least that is how it is in IM 6. IM 7 may be different.