Using pi2 from shell or command line¶
Pi2 can be used as a standalone program from the shell (Linux) or command prompt (Windows). There are two ways to achieve this.
With a Pi2 script file¶
Create a text file that contains Pi2 commands that you want to run, e.g:
newimage(img, uint8, 100, 100, 100);
noise(img, 100, 25);
writetif(img, ./noise);
Save the file and then run:
./pi2 file_name
or in Windows:
pi2 file_name
where file_name
is the name of the script file.
If no file name is given, the program tries to open pi.txt
or pi2.txt
in the current directory and use that as an input file.
Without intermediate script file¶
The Pi2 commands can be given directly as command-line arguments to the pi2 executable. For example, in Linux:
./pi2 "newimage(img, uint8, 100, 100, 100); noise(img, 100, 25); writetif(img, ./noise);"
or in Windows:
pi2 newimage(img, uint8, 100, 100, 100); noise(img, 100, 25); writetif(img, ./noise);
Pi2 command syntax¶
The syntax of the Pi2 script files (and command-lines) is pretty simple and forgiving. There are only a few rules:
- Each command is in the form
name(arg1, arg2, ..., argN)
. There are no, e.g. arithmetic operations or conditional statements. List of allowed commands is found in the Command reference page.- Commands can be separated by
;
-character or newline. Newlines can be in either Linux or Windows format.- Whitespace is not significant. Values do not need to be quoted unless they contain significant whitespace or commas, and in that case they may be quoted either with single quotes
'
or double quotes"
.- Anything after
%
,#
, or//
is comment until the next newline.- Vector values can be expressed with
[x, y, z]
, wherex
,y
, andz
are the three components of the vector. If only one componentx
is specified, the resulting vector will be[x, x, x]
.- Image names must be alphanumeric and start with a letter.
- Argument that has a default value does not need to be given, unless arguments after that are given.