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.

For simple evaluations (e.g. 20 + 5), booleans, comparisons, and more, you can wrap your expression in double-brackets ([[ … ]]).

Color Values

Color strings are processed using PIL.ImageColor.getcolor(color_str, "RGBA"). Accepted formats include #RRGGBB, rgba(...), and named colors.

Numeric Values

Supports inline math and methods:

w: "100"
x: "{var: x}" # Previously assigned variable.
y: "[[ 20/2 + (10 * 10) - 10 ]]"
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


Inline Methods (Always Parsed)

Double-bracket parsing

Escaping Brackets

Examples

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} ]]"