Vips.Image.system
Description: Reference for Vips.Image.system

### Constructor

# Vips Imagesystem

#### Declaration [src]

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

#### Description [src]

`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.

If `cache` is set, this call will be added to the libvips operation cache and reused if possible.

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",
            "cache", TRUE,
            "log", &log,
            NULL))
        error ...

Optional arguments

- `in`: `VipsArrayImage`, array of input images
- `out`: `VipsImage`, output, image
- `in_format`: `gchararray`, write input files like this
- `out_format`: `gchararray`, write output filename like this
- `cache`: `gboolean`, cache this call
- `log`: `gchararray`, output, stdout of command is returned here.

This constructor is not directly available to language bindings.

#### Parameters

`cmd_format`

  Type: `const char*`

  Command to run.

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

`...`

  Type: ``

  `NULL`-terminated list of optional named arguments.

#### Return value

Type: `int`

0 on success, -1 on failure.