string formats to fx constants

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Post Reply
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

string formats to fx constants

Post by fmw42 »

Just so I know how to handle things such as %[min], %[max], %[mean], %[standard-deviation] in my scripts, I don't see them any longer on http://www.imagemagick.org/script/escape.php as of 6.4.0-11, but now see image.minima, image.maxima, image.mean, image.standard_deviation on http://www.imagemagick.org/script/fx.php

Does that mean that the former are no longer available in 6.4.0-11?

If true, then I will put an IM version trap in my scripts to replace the older style with the newer style for releases >= 6.4.0-11. (I don't mean to look a gift-horse in the mouth, but when I raised the question of combining computations I did not expect that the older style would be removed completely. However, from a point of redundancy, I can understand if that is what you have done.)

Also in the former, you had %[standard-deviation] with a hyphen and now you have image.standard_deviation with an underscore. Is this correct or is there a typo?

I have not yet updated to 6.4.0-11 and am still on 6.4.0-10 and would like to understand the situation before upgrading, so I can plan on changes to my scripts.

I am also curious as to why you needed to use the "image." prefix to these variables. (Other things like intensity, hue, saturation, etc, which are also image dependent do not seem to start with "image.". I can understand why you could not use min an max, but minima and maxima do not conflict with the min and max operators)? This is not terribly important. Whatever you decided is fine and I can work with it. I am just curious about the rationale?

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

Re: string formats to fx constants

Post by magick »

%[min], %[max], %[mean], %[standard-deviation] are deprecated but still supported.

image.standard_deviation is the correct usage. Fx has a simple parser. It would interpret '-' as a subtract operation.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: string formats to fx constants

Post by fmw42 »

Thanks for the explanation. Being deprecated but supported makes it less urgent for me to rework all my scripts.

Still curious about why the need for the "image." prefix? If you have time to respond. If not, then not terribly important.

Thanks for all your work on this.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: string formats to fx constants

Post by magick »

ImageMagick uses namespaces wherever possible. The image namespace is for attributes that apply to the entire image rather than an individual pixel. It also permits us to add additional attributes in the future. So far we have:
  • image.resolution.x = x resolution
    image.resolution.y = y resolution
    image.depth = image depth
    image.minima = image minima
    image.maxima = image maxima
    image.mean = image mean
    image.standard_deviation = image standard deviation
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: string formats to fx constants

Post by fmw42 »

I just upgraded to IM 6.4.0-11 and wanted to confirm to you that the new image.minima, etc work fine.

convert rose: -format "%[min]" info:
5654
convert rose: -format "%[max]" info:
65535
convert rose: -format "%[mean]" info:
27022.8
convert rose: -format "%[standard-deviation]" info:
16982.2

convert rose: -format "%[fx:Quantumrange*image.minima]" info:
5654
convert rose: -format "%[fx:Quantumrange*image.maxima]" info:
65535
convert rose: -format "%[fx:Quantumrange*image.mean]" info:
27022.8
convert rose: -format "%[fx:Quantumrange*image.standard_deviation]" info:
16982.2
Post Reply