2014-07-25 10:22:49 +02:00
|
|
|
<?xml version="1.0"?>
|
2014-11-16 19:01:19 +01:00
|
|
|
<!-- vim: set ts=2 sw=2 expandtab: -->
|
2014-07-25 10:22:49 +02:00
|
|
|
<!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
|
|
|
|
"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
|
|
|
]>
|
|
|
|
<refentry id="using-cli">
|
|
|
|
<refmeta>
|
|
|
|
<refentrytitle>VIPS from the command-line</refentrytitle>
|
|
|
|
<manvolnum>1</manvolnum>
|
|
|
|
<refmiscinfo>VIPS Library</refmiscinfo>
|
|
|
|
</refmeta>
|
|
|
|
|
|
|
|
<refnamediv>
|
|
|
|
<refname>Using VIPS</refname>
|
2014-08-06 22:59:13 +02:00
|
|
|
<refpurpose>How to use the VIPS library from the command-line</refpurpose>
|
2014-07-25 10:22:49 +02:00
|
|
|
</refnamediv>
|
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-intro">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Introduction</title>
|
2014-07-25 10:22:49 +02:00
|
|
|
<para>
|
|
|
|
Use the <command>vips</command> command to execute VIPS operations from
|
2015-01-28 10:50:15 +01:00
|
|
|
the command-line. For example:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
$ vips rot k2.jpg x.jpg d90
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
Will rotate the image <literal>k2.jpg</literal> by 90 degrees
|
|
|
|
anticlockwise and write the result to the file <literal>x.jpg</literal>.
|
|
|
|
If you don't give any arguments to an operation,
|
|
|
|
<command>vips</command> will give a short description, for example:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
$ vips rot
|
|
|
|
rotate an image
|
|
|
|
usage:
|
|
|
|
rot in out angle
|
|
|
|
where:
|
|
|
|
in - Input image, input VipsImage
|
|
|
|
out - Output image, output VipsImage
|
|
|
|
angle - Angle to rotate image, input VipsAngle
|
|
|
|
default: d90
|
|
|
|
allowed: d0, d90, d180, d270
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
There's a straightforward relationship with the C API: compare this to
|
|
|
|
the API docs for vips_rot(), for example.
|
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-list">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Listing all operations</title>
|
|
|
|
<para>
|
|
|
|
You can list all classes with:
|
|
|
|
|
|
|
|
<programlisting>
|
2015-04-21 17:41:03 +02:00
|
|
|
$ vips -l
|
2015-01-28 10:50:15 +01:00
|
|
|
...
|
|
|
|
VipsOperation (operation), operations
|
|
|
|
VipsSystem (system), run an external command
|
|
|
|
VipsArithmetic (arithmetic), arithmetic operations
|
|
|
|
VipsBinary (binary), binary operations
|
|
|
|
VipsAdd (add), add two images
|
|
|
|
... etc.
|
|
|
|
</programlisting>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
|
|
|
Each line shows the canonical name of the class (for example
|
|
|
|
<literal>VipsAdd</literal>), the class nickname
|
|
|
|
(<literal>add</literal> in this case), and a short description.
|
2015-01-28 10:50:15 +01:00
|
|
|
Some subclasses of operation will show more: for example, subclasses of
|
2014-07-25 10:22:49 +02:00
|
|
|
<literal>VipsForeign</literal> will show some of the extra flags
|
|
|
|
supported by the file load/save operations.
|
2015-01-28 10:50:15 +01:00
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-options">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Optional arguments</title>
|
|
|
|
<para>
|
|
|
|
Many operations take optional arguments. You can supply these as
|
|
|
|
command-line options, for example:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
$ vips gamma
|
|
|
|
gamma an image
|
|
|
|
usage:
|
|
|
|
gamma in out
|
|
|
|
where:
|
|
|
|
in - Input image, input VipsImage
|
|
|
|
out - Output image, output VipsImage
|
|
|
|
optional arguments:
|
|
|
|
exponent - Gamma factor, input gdouble
|
|
|
|
default: 2.4
|
|
|
|
min: 1e-06, max: 1000
|
|
|
|
operation flags: sequential-unbuffered
|
|
|
|
</programlisting>
|
|
|
|
|
|
|
|
vips_gamma() applies a gamma factor to an image. By
|
2014-07-25 10:22:49 +02:00
|
|
|
default, it uses 2.4, the sRGB gamma factor, but you can specify any
|
2015-01-28 10:50:15 +01:00
|
|
|
gamma with the <literal>exponent</literal> option.
|
|
|
|
</para>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<para>
|
2014-07-25 10:22:49 +02:00
|
|
|
Use it from the command-line like this:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
|
|
|
$ vips gamma k2.jpg x.jpg --exponent 0.42
|
|
|
|
</programlisting>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
|
|
|
This will read file <literal>k2.jpg</literal>, un-gamma it, and
|
|
|
|
write the result to file <literal>x.jpg</literal>.
|
2015-01-28 10:50:15 +01:00
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-array">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Array arguments</title>
|
|
|
|
<para>
|
2014-07-25 10:22:49 +02:00
|
|
|
Some operations take arrays of values as arguments, for example,
|
2015-01-28 10:50:15 +01:00
|
|
|
vips_affine() needs an array of four numbers for the
|
2014-07-25 10:22:49 +02:00
|
|
|
2x2 transform matrix. You pass arrays as space-separated lists, for
|
|
|
|
example:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
|
|
|
$ vips affine k2.jpg x.jpg "2 0 0 1"
|
|
|
|
</programlisting>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
You may need the quotes to stop your shell breaking the argument at
|
|
|
|
the spaces. vips_bandjoin() needs an array of input images to
|
2014-07-25 10:22:49 +02:00
|
|
|
join, run it like this:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
|
|
|
$ vips bandjoin "k2.jpg k4.jpg" x.tif
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-conversion">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Implicit file format conversion</title>
|
|
|
|
<para>
|
2014-07-25 10:22:49 +02:00
|
|
|
<command>vips</command> will automatically convert between image file
|
|
|
|
formats for you. Input images are detected by sniffing their first few
|
|
|
|
bytes; output formats are set from the filename suffix. You can see a
|
|
|
|
list of all the supported file formats with something like:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
2015-04-21 17:41:03 +02:00
|
|
|
$ vips -l foreign
|
2015-01-28 10:50:15 +01:00
|
|
|
</programlisting>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
|
|
|
Then get a list of the options a format supports with, for example:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
|
|
|
$ vips jpegsave
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<para>
|
2014-07-25 10:22:49 +02:00
|
|
|
You can pass options to the implicit load and save operations enclosed
|
|
|
|
in square brackets after the filename. For example:
|
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<programlisting>
|
|
|
|
vips affine k2.jpg x.jpg[Q=90,strip] "2 0 0 1"
|
|
|
|
</programlisting>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
|
|
|
Will write <literal>x.jpg</literal> at quality level 90 and will
|
|
|
|
strip all metadata from the image.
|
2015-01-28 10:50:15 +01:00
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2015-04-21 17:41:03 +02:00
|
|
|
|
|
|
|
<refsect3 id="using-command-line-chaining">
|
|
|
|
<title>Chaining operations</title>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
Because each operation runs in a separate process, you can't use
|
|
|
|
libvips's chaining system to join operations together, you have to use
|
|
|
|
intermediate files. The command-line interface is therefore quite a bit
|
|
|
|
slower than Python or C.
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
The best alternative is to use vips files for intermediates.
|
|
|
|
Something like:
|
|
|
|
|
|
|
|
<programlisting>
|
|
|
|
vips invert input.jpg t1.v
|
|
|
|
vips affine t1.v output.jpg "2 0 0 1"
|
|
|
|
rm t1.v
|
|
|
|
</programlisting>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
</refsect3>
|
2015-01-28 10:50:15 +01:00
|
|
|
|
2015-02-23 13:32:56 +01:00
|
|
|
<refsect3 id="using-command-line-other">
|
2015-01-28 10:50:15 +01:00
|
|
|
<title>Other features</title>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
2015-01-28 10:50:15 +01:00
|
|
|
<para>
|
2014-07-25 10:22:49 +02:00
|
|
|
Finally, <command>vips</command> has a couple of useful extra options.
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Use <option>--vips-progress</option> to get
|
|
|
|
<command>vips</command> to display a simple progress indicator.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Use <option>--vips-leak</option> and <command>vips</command> will
|
|
|
|
leak-test on exit, and also display an estimate of peak memory use.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
2017-01-04 15:45:35 +01:00
|
|
|
|
|
|
|
<listitem>
|
|
|
|
<para>
|
|
|
|
Set <code>G_MESSAGES_DEBUG=VIPS</code> and GLib will display
|
|
|
|
informational and debug messages from libvips.
|
|
|
|
</para>
|
|
|
|
</listitem>
|
|
|
|
|
2014-07-25 10:22:49 +02:00
|
|
|
</itemizedlist>
|
|
|
|
</para>
|
|
|
|
|
|
|
|
<para>
|
|
|
|
VIPS comes with a couple of other useful programs.
|
|
|
|
<command>vipsheader</command> is a command which can print image header
|
|
|
|
fields. <command>vipsedit</command> can change fields in vips format
|
|
|
|
images. <command>vipsthumbnail</command> can make image thumbnails
|
|
|
|
quickly.
|
|
|
|
</para>
|
2015-02-23 13:32:56 +01:00
|
|
|
</refsect3>
|
2014-07-25 10:22:49 +02:00
|
|
|
|
|
|
|
</refentry>
|