+
-
-
-
-
+
+
+
@@ -226,15 +241,15 @@
constants:
e, Epsilon, QuantumRange, QuantumScale, Opaque, Pi, Transparent
Fx operators (in order of precedence):
-
^ (power), *, /, % (modulo), +, -,
+ ^ (power), unary -, *, /, % (modulo), +, -,
<<, >>, <, <=, >, >=, ==, !=,
& (bitwise AND), | (bitwise OR),
&& (logical AND), || (logical OR),
~ (logical NOT), ?: (ternary conditional)
math functions:
-
abs(), acos(), alt(), asin(), atan(), atan2(), ceil(), cos(), cosh(), debug(), exp(), floor(),
- hypot(), int(), ln(), log(), logtwo(), max(), min(), mod(), pow(), rand(), round(),
- sign(), sin(), sinh(), sqrt(), tan(), tanh()
+
abs(), acos(), airy(), alt(), asin(), atan(), atan2(), ceil(), cos(), cosh(), debug(), exp(), floor(),
+ hypot(), int(), j0(), j1(), jinc(), ln(), log(), logtwo(), max(), min(), mod(), pow(), rand(), round(),
+ sign(), sin(), sinc(), sinh(), sqrt(), tan(), tanh(), trunc()
channel functions:
channel(r,g,b,a), channel(c,m,y,k,a)
color names:
@@ -343,6 +358,7 @@
s, t, u, v, n, i, j, w, h, z, r, g, b, a, o, c, y, m, k: symbols
abs(x): absolute value function
acos(x): arc cosine function
+
airy(x): Airy function (max=1, min=0); airy(x)=[jinc(x)]2=[2*j1(pi*x)/(pi*x)]2
alt(x): sign alternation function (return 1.0 if int(x) is even, -1.0 if int(x) is odd)
asin(x): arc sine function
atan(x): arc tangent function
@@ -357,6 +373,9 @@
floor(x): largest integral value not greater than argument
hypot(x,y): the square root of x2+y2
int(x): greatest integer function (return greatest integer less than or equal to x)
+
j0(x): Bessel functions of x of the first kind of order 0
+
j1(x): Bessel functions of x of the first kind of order 1
+
jinc(x): jinc function (max=1, min=-0.1323); jinc(x)=2*j1(pi*x)/(pi*x)
ln(x): natural logarithm function
log(x): logarithm base 10
logtwo(x): logarithm base 2
@@ -369,10 +388,12 @@
round(): round to integral value, regardless of rounding direction
sign(x): return -1.0 if x is less than 0.0 otherwise 1.0
sin(x): sine function
+
sinc(x): sinc function (max=1, min=-0.21); sinc(x)=sin(pi*x)/(pi*x)
sinh(x): hyperbolic sine function
sqrt(x): square root function
tan(x): tangent function
tanh(x): hyperbolic tangent function
+
trunc(x): round to integer, towards zero
The expression semantics include these rules:
@@ -383,8 +404,11 @@
statements are assignments or the final expression to return
an assignment starts a statement, it is not an operator
assignments to built-ins do not throw an exception and have no effect; e.g. r=3.0; r returns the pixel red color value, not 3.0
+
Unary operators have a lower priority than binary operators, that is, the unary minus (negation) has lower precedence than exponentiation, so -3^2 is interpreted as -(3^2) = -9. Use parentheses to clarify your intent (e.g. (-3)^2 = 9).
+
Similarly, care must be exercised when using the slash ('/') symbol. The string of characters 1/2x is interpreted as (1/2)x. The contrary interpretation should be written explicitly as 1/(2x). Again, the use of parentheses helps clarify the meaning and should be used whenever there is any chance of misinterpretation.
+
Source Images
@@ -397,7 +421,7 @@
$magick> convert image1.jpg image2.jpg image3.jpg -fx "(u+u[2])/2.0" image.jpg
By default, the image to which p, r, g, b, a, etc., are applied is the first image u in the image list, which may also be referenced using s.
-
It is important to note the special role played by the first image. This is the only image in the image sequence that is modified, any other images being used only for their data. As an illustrative example, comsider the following, and note that the setting -channel red instructs -fx to modify only the red channel; nothing in the green or blue channels will change. It is instructive to ponder why the result is not symmetric.
+
It is important to note the special role played by the first image. This is the only image in the image sequence that is modified, other images are used only for their data. As an illustrative example, consider the following, and note that the setting -channel red instructs -fx to modify only the red channel; nothing in the green or blue channels will change. It is instructive to ponder why the result is not symmetric.
$magick> convert -channel red logo: -flop logo: -resize "20%" -fx "(u+v)/2" image.jpg
@@ -458,6 +482,8 @@
$magick> convert xc:'rgb(25%,50%,75%)' rose: -colorspace rgb \
-format 'Red channel of NW corner of image # %[fx:t] is %[fx: s]' info:Red channel of NW corner of image # 0 is 0.250004
Red channel of NW corner of image # 1 is 0.188235
+
Use %[fxc: ] if your expression is a constant (e.g. %[fxc:page.x/2]. The result is cached and the cached result returned rather than evaluating the expression each time.
+
The color-escape %[pixel: ] is evaluated once per image and per color channel in that image (-channel is ignored), The values generated are then converted into a color string (a named color or hex color value). The symbols i and j are set to zero, and s and t refer to each successively current image and index.
@@ -466,10 +492,10 @@