@@ -28,7 +28,8 @@ There are three principal modes:
2828.B nip4-batch filename [ arg1.. ]
2929Load filename as a set of definitions and pass in any other arguments as
3030argc and argv. This is the default mode and is suitable for writing scripts
31- in nip4's programming language.
31+ in nip4's programming language. In this mode it will function as a shebang
32+ interpreter.
3233
3334.TP
3435.B nip4-batch -e expression [ arg1.. ]
@@ -111,5 +112,34 @@ Load argv1 (fred.jpg), add 99, output to result.png.
111112.B nip4-batch -e "Matrix [[1,2],[4,5]] ** -1" -o poop.mat
112113Invert the 2x2 matrix and write the result to poop.mat.
113114
115+ .SH SHEBANG
116+
117+ You can use nip4-batch as a shebang interpreter. For example, this file
118+
119+ .nf
120+ .ft 6
121+ #!/usr/bin/env nip4-batch
122+
123+ main
124+ = error "usage: infile -o outfile", argc != 2
125+ = (sharpen @ shrink @ crop) (Image_file argv?1)
126+ {
127+ crop x = extract_area 100 100 (x.width - 200) (x.height - 200) x;
128+ shrink = resize Kernel_linear 0.9 0.9;
129+ sharpen = conv (Matrix_con 8 0 [[-1, -1, -1], [-1, 16, -1], [-1, -1, -1]]);
130+ }
131+ .fi
132+ .ft
133+
134+ When saved to a file called "process" can be executed from your shell like this:
135+
136+ .nf
137+ .ft 6
138+ $ ./process a.jpg -o b.jpg
139+ .fi
140+ .ft
141+
142+ Meaning load from a.jpg, process, and save to b.jpg.
143+
114144.SH COPYRIGHT
1151452025 (c) libvips.org
0 commit comments