nip4-batch(1)
| NIP4-BATCH(1) | General Commands Manual | NIP4-BATCH(1) |
NAME
nip4-batch - command-line interface to the nip4 image processing spreadsheet
SYNOPSIS
nip4-batch filename [arg1..]
nip4-batch -e expression [arg1..]
nip4-batch -w [filename1..]
DESCRIPTION
nip4-batch is a command-line interface to the nip4(1) image processing spreadsheet.
There are three principal modes:
- nip4-batch filename [ arg1.. ]
- Load filename as a set of definitions and pass in any other arguments as argc and argv. This is the default mode and is suitable for writing scripts in nip4's programming language. In this mode it will function as a shebang interpreter.
- nip4-batch -e expression [ arg1.. ]
- Set main = expression, set argc and argc to any remaining arguments, and print the value of symbol "main" to stdout.
- nip4-batch -w [ filename1.. ]
- Load the named files as workspaces or images. You can use the options below to pass the workspace parameters and control what workspace results are saved or printed.
Command Line Options
These options give more precise control over nip4-batch's behaviour.
- --workspace
- Load arguments as workspaces.
- --expression=expression
- Evaluate expression and print the result to stdout. Any other arguments are loaded as argc and argv.
- --output=filename
- The value of main is written to filename. If main is a list, the filename is incremented between objects. You can use the suffix to specify the format and options to write in.
- --print-main
- Print the value of main on exit. nip4-batch will check for a top-level symbol called main, and also check each workspace for a main.
Debugging Options
Some other options are useful for debugging, benchmarking, and for generating strings for internationalisation.
- --verbose
- Produce verbose error messages: handy for debugging in batch mode.
- --i18n
- Output strings from .def files for internationalisation.
- --version
- Print version information.
- --test
- Start up (including any arg processing), test for any errors, and exit with an error code if any occurred. Useful for running automated tests.
- --prefix=PREFIX
- Set install prefix. Start up as if nip4-batch had been installed to PREFIX. Useful for running automated tests without installing the thing.
EXAMPLES
- nip4-batch -e 2 + 2
- Prints 4 to stdout.
- nip4-batch -e 99 + Image_file argv?1 -o result.png fred.jpg
- Load argv1 (fred.jpg), add 99, output to result.png.
- nip4-batch -e Matrix [[1,2],[4,5]] ** -1 -o poop.mat
- Invert the 2x2 matrix and write the result to poop.mat.
SHEBANG
You can use nip4-batch as a shebang interpreter. For example, this file
#!/usr/bin/env nip4-batch
main
= error "usage: infile -o outfile", argc != 2
= (sharpen @ shrink @ crop) (Image_file argv?1)
{
crop x = extract_area 100 100 (x.width - 200) (x.height - 200) x;
shrink = resize Kernel_linear 0.9 0.9;
sharpen = conv (Matrix_con 8 0 [[-1, -1, -1], [-1, 16, -1], [-1, -1, -1]]);
}
When saved to a file called "process" can be executed from your shell like this:
$ ./process a.jpg -o b.jpg
Meaning load from a.jpg, process, and save to b.jpg.
COPYRIGHT
2025 (c) libvips.org
| Oct 4 2025 |
