Advanced Parsing Overview
Inline Methods
Dynamic substitutions allow value calculation:
width: "{width:source}" # Width from the input "source".
height: "{height:source}" # Height from the input "source".
random_int: "{random:5,10}"
random_float: "{random:5.0,10.0}"
var: "{var:myvar}" # Value from previously assigned variable 'myvar'.
condition: "{exists:cache/mask.png}" # 1 if file exists. 0 if not.
Parsing
By default, any inline methods, like {var:…}, {random:…}, {exists:…}, {width:…}, and {height:…}are automatically evaluated.
Numeric Values
Supports inline math and methods:
w: "100"
x: "{var: x}" # Previously assigned variable.
y: "[[ 20/2 + (10 * 10) - 10 ]]" # Double bracket encapsulated content is evaluated.
z: "[[ {width:source}/2 ]]" # Inline math using input metadata.
Point Values
Coordinates can be specified as absolute or relative:
Absolute:
anchor: "(100,20)"
anchor2: "([[50*2]], {height:source})"
Relative:
relative_anchor: "rel(0.5,0.5)" # Relative to contextual value.
Behavior and Inheritance
-
Variable Inheritance:
Nested jobs inherit the parent's variables (including those set via assign blocks) for inline substitutions. -
Override Inheritance:
Nested jobs inherit a copy of the parent's structured overrides, merged into the nested job's definition during execution. -
Isolation:
Changes within a nested job (including overrides and variable assignments) do not affect the parent job.
Inline Methods (Always Parsed)
- What:
{var:…},{exists:…},{random:…},{width:…},{height:…},rel(…), etc. - When: Always applied first, on every value, before any math or condition logic.
- Nesting: If you write an inline method inside another (e.g.
{var:myvar{random:1,10}}), the inner{random:…}runs first, then its result feeds into the outer{var:…}lookup.
Double-bracket parsing
- Trigger: Any value containing
[[…]]. - Scope: Only the text inside each
[[…]]is evaluated—everything else remains exactly as written. - Capabilities:
- Full boolean & comparison logic
- Ternary expressions (
a if cond else b) - Tuple math (
(x+5, y*0.5)) - Math functions (
abs(),round(),min(),max(),math.floor(), etc.) - Inline methods can still be used inside
[[…]].
Escaping Brackets
- To include literal
[[or]]without triggering advanced evaluation, prefix them with a backslash:message: "\[\[ escaped double brackets \]\]"
-
You can mix escapes and eval:
text: "\[\[unparsed\]\] 2+2=[[ 2 + 2 ]]" # → "[[unparsed]] 2+2=4"
Examples
-
Arithmetic & Math
+ - * / % **- e.g.
[[ ({var:width} + {var:padding}) * 2 ]]
-
Booleans & Comparisons
and,or,not<, <=, >, >=, ==, !=- e.g.
[[ not {var:done} ]] - e.g.
[[ {var:count} > 3 and {var:flag} ]]
-
Ternary (Conditional) Expressions
a if cond else b- e.g.
[[ {var:padding} if {var:width} > 1000 else 10 ]]
-
Math Functions
abs(),round(),min(),max(),math.floor(),math.ceil(),math.sqrt()- e.g.
[[ round( max({var:width}, {var:height}) / 2 ) ]]
-
Inline Methods Inside Brackets
- You can mix any inline method inside your bracketed expressions:
{var:…}for variables{exists:…}for file existence{random:…},{width:…},{height:…}, etc.
- You can mix any inline method inside your bracketed expressions:
Examples
# 1) Conditional step
- processor:
processor: "trim"
condition: "[[ {width:source} > 800 ]]"
# 2) Ternary padding
params:
padding: "[[ {var:padding} if {width:source} >= 1024 else 10 ]]"
# 3) Composite anchors with tuple math
- processor:
processor: "composite"
params:
overlay_anchor: " ( [[{width:background}/2]], [[{height:background}/2]] ) "
# 4) Boolean + exists + var
- processor:
processor: "inpaint"
condition: '[[ "{exists:cache/mask.png}" and not {var:skipped} ]]'
# 5) Using math functions
params:
blur_radius: "[[ round( {var:shadow_scale} * 2.5 ) ]]"
# 6) Comparison with multiple vars
- processor:
processor: "example"
condition: "[[ {var:count} > 3 and {var:enabled} ]]"
Color Values
Color strings can be written in several formats. All are interpreted as RGBA values — red, green, blue, and alpha (opacity) — where each channel is in the range 0–255.
Supported Formats
-
Hexadecimal
-
"#RRGGBB"— six-digit hex code- Example:
"#FF00FF"→ (255, 0, 255, 255)
- Example:
-
"#RRGGBBAA"— eight-digit hex code (last two digits are alpha)- Example:
"#FF00FF80"→ (255, 0, 255, 128)
- Example:
-
-
RGB / RGBA functions
-
"rgb(r, g, b)"— each channel 0–255- Example:
"rgb(255, 0, 128)"→ (255, 0, 128, 255)
- Example:
-
"rgba(r, g, b, a)"— last value is opacity-
Can be 0–255 (integer) or 0.0–1.0 (float)
-
Examples:
"rgba(255, 0, 128, 0.5)"→ (255, 0, 128, 128)"rgba(255, 0, 128, 128)"→ (255, 0, 128, 128)
-
-
-
Named Colors Common CSS color names are supported, such as:
"white","black","red","green","blue","yellow","cyan","magenta", etc. -
Transparent The keyword
"transparent"maps to(0, 0, 0, 0).
Notes
- Alpha (opacity) defaults to 255 (fully opaque) if not specified.
- Float alpha values (like
0.5) are scaled to 0–255. - Invalid formats will raise an error.