One of the big new features is optional output arguments. For example, VipsMin is an operation that finds the minimum value of an image. You can run it from the command-line like this:
Very similar to the old im_min. But now there are also optional output arguments to get the position of the minimum:$ vips min fred.jpg
12
and you get the same API in Python, Ruby, Javascript, nip2, C and C++:$ vips min --x --y fred.jpg
12
2345
245
Args only need a few of lines of code to add to a class and everything else is generated for you automatically at runtime. For example, the optional --x arg for VipsMin is declared like this:>> m = im.min()
>> print m
12
>> m, x, y = im.min("x", "y")
VipsImage *fred;
double m;
int x, y;
vips_min( fred, &m,
"x", &x,
"y", &y,
NULL );
That binds an optional int arg with the range locked to 0 to 10000000 to the member x of the class VipsMin. Your bit of C just needs to assign that member and the value will appear in all languages and all interfaces.VIPS_ARG_INT( class, "x", 2,
_( "x" ), _( "Horizontal position of minimum" ),
VIPS_ARGUMENT_OPTIONAL_OUTPUT,
G_STRUCT_OFFSET( VipsMin, x ),
0, 1000000, 0 );
VipsJoin has one of the fanciest ones. At a minimum it's:
to join two images left-right, but there are also extra optional arguments, for example:$ vips join left.v right.v out.v horizontal
to join left-right with a 50 pixel gap, the output expanded to hold all of both left and right, and the background painted green.$ vips join --expand --background 0,255,0 --align centre --shim 50 left.v right.v out.v horizontal
You can get a summary of the options by running with no args:
vips8 includes full vips7 compatibility. The old interface:$ vips join
VipsJoin (join), join an image
join in1 in2 out direction
where:
in1 :: VipsImage (input)
in2 :: VipsImage (input)
out :: VipsImage (output)
direction :: VipsDirection (input)
optional arguments:
align :: VipsAlign (input)
expand :: gboolean (input)
shim :: gint (input)
background :: VipsArrayDouble (input)
join: too few arguments
VipsObject: parameter in1 to VipsJoin not set
VipsObject: parameter in2 to VipsJoin not set
VipsObject: parameter direction to VipsJoin not set
is still there and still works well.$ vips im_lrjoin left.v right.v out.v
No comments:
Post a Comment