DrawShield From the Command Line

From DrawShield Documentation

Locally Installed DrawShield

It is possible to run DrawShield by installing it on your system and invoking it from the command line.

Pre-requisites

You will need PHP8.1 or above (8.2 may generate deprecation warnings). You will need PHP extensions for libxml and possibly some others, you should get warning messages about what is needed.

The basic program will produce SVG files. For conversion to other formats I suggest installing ImageMagick and using its 'convert' program.

DrawShield from the command line

Basic Use

At it simplest, running DrawShield from the command line will just concatenate all of the arguments into a single string, separated by spaces and this will be treated as the blazon. A file named shield.png will be created which will be 500 pixels wide, using the DrawShield colour scheme, the heater shield shape and the shiny effect.

The program should be run from the top level directory containing the drawshield code. An example command line would be:

php drawshield.php azure a bend or

Advanced use

You can also set the same options as the API by using command line arguments of the form:

argument=“value”

Where ‘argument’ is the same as shown on the API page and value is the chosen value. If you use this method to set the blazon it should be a single, URL encoded value.

Any remaining arguments (i.e. not starting with ‘-‘) will be concatenated with spaces and used as the blazon, for example:

php drawshield.php —-effect=stonework —-shape=french argent a cross wavy gules


Debugging

If there are no arguments at all the program will instead look for a file in the same folder named ‘debug.inc’. If this exists it will be “included” and hence should consist of PHP code. Most usefully this code should set the various values of the $options array, for example:

$options[“blazon”] = ”azure a bend or“;

You can also set other options as required. This is the suggested method for using a PHP debugger.