Function

Vipssystem

Declaration [src]

int
vips_system (
  const char* cmd_format,
  ...
)

Description [src]

Optional arguments:

  • in: array of input images
  • out: output image
  • in_format: write input files like this
  • out_format: write output filename like this
  • log: stdout of command is returned here

vips_system() runs a command, optionally passing a set of images in and optionally getting an image back. The command’s stdout is returned in log.

First, if in is set, the array of images are written to files. See vips_image_new_temp_file() to see how temporary files are created. If in_format is something like %s.png, the file will be written in PNG format. By default, in_format is %s.tif.

If out_format is set, an output filename is formed in the same way. Any trailing [options] are stripped from out_format.

The command string to run is made by substituting the first set of %s in cmd_format for the names of the input files, if in is set, and then the next %s for the output filename, if out_format is set. You can put a number between the % and the s to change the order in which the substitution occurs.

The command is executed with popen() and the output captured in log.

After the command finishes, if out_format is set, the output image is opened and returned in out. You can append [options] to out_format to control how this open happens. Closing out image will automatically delete the output file.

Finally the input images are deleted.

For example, this call will run the ImageMagick convert program on an image, using JPEG files to pass images into and out of the convert command.

VipsArrayImage *in;
VipsImage *out;
char *log;

if (vips_system ("convert %s -swirl 45 %s",
    "in", in,
    "out", &out,
    "in_format", "%s.jpg",
    "out_format", "%s.jpg",
    "log", &log,
    NULL))
    error ...
This function is not directly available to language bindings

Parameters

cmd_format const char*
 

Command to run.

 The data is owned by the caller of the function.
 The value is a NUL terminated UTF-8 string.
...
 

NULL-terminated list of optional named arguments.

Return value

Returns: int
 

0 on success, -1 on failure.