Type to search...

If

The conditions allow to run or not to run image transformations based on those conditions.

if

It is useful when we are not familiar with things on the input image (base image) and we would like certain changes to occur based on the results of the transformations.

Formats

  • if(<conditions>)
  • if(<conditions>)_<transformations>/.../if:end
  • if(<conditions>)_<transformations>/.../if:else/<transformations>/
  • if(<conditions>)_<transformations>/.../if:else/<transformations>/.../if:end
  • if(<conditions>)_<transformations>/.../if:elseif(<conditions>)/.../<transformations>/
  • if(<conditions>)_<transformations>/.../if:elseif(<conditions>)/<transformations>/.../if:end

Building the condition

A condition is made up of three elements: left side operandus, operator, right side operandus

<left side operandus>,<operator>,<right side operandus>

Conditions

The conditions can be linked using logical operations like _or_ and_and_. When interpreting, the OR operations run first, then the AND operations.

Operators

  • eq, equ: equal
  • ne, neq: not equal
  • lt, lss: left side operator is smaller than the right side
  • gt, gtr: left side operator is larger than the right side
  • le, leq: left side operator is smaller than or equal to the right side
  • ge, geq: left side operator is larger than or equal to the right side

Operanduses

  • iw, init-width: starting pixel width [px]
  • ih, init-height: starting pixel height [px]
  • gw, group-width: group starting image pixel width [px]
  • gh, group-height: group starting image pixel height [px]
  • ar, aspect-ratio: aspect ratio group-width / group-height
  • fc, face-count: number of detected faces
  • integer
  • floating point number (decimal character of .)

Limitations

  • This transformation does not have any limitations.

Dependencies

  • This transformation does not have any dependencies.

Examples

If aspect-ratio (ar) lower than 1.0 then set border to the right and left side, else set border to the up and bottom side.

w:200/if(ar,lt,1.0)_bo:0,4,0,4_co:red/if:else_bo:4,0,4,0_co:red
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(200)->group()->ifIf('ar,lt,1.0')->border(0,4,0,4)->color('red')->group()->ifElse()->border(4,0,4,0)->color('red');

Same condition but the else condition fulfilled.

w:200/if(ar,lt,1.0)_bo:0,4,0,4_co:red/if:else_bo:4,0,4,0_co:red
use shardimage\shardimagephp\factories\Transformation;
$transformations = (new Transformation())->width(200)->group()->ifIf('ar,lt,1.0')->border(0,4,0,4)->color('red')->group()->ifElse()->border(4,0,4,0)->color('red');
Table of contents