Linux Absolute Beginners #2 : How to use Vips – best image processing program ever

in #linux5 years ago (edited)

You may think I'm joking as vips is probably also one of the least intuitive image processing programs that exist. But it is the fastest one that I know of (please, correct me if I'm wrong). It was created for all the image processing work done at the National Gallery in London. Obviously, it is most useful with really big images, which make all other programs stall. It can be installed on Debian based systems like this:

apt-get install libvips-tools

Range of its operations is probably large enough for all your image processing needs. You can list all operations with:

vips -l|less

which gives a huge list

 VipsOperation (operation), operations
    VipsSystem (system), run an external command
    VipsArithmetic (arithmetic), arithmetic operations
     VipsBinary (binary), binary operations
        VipsAdd (add), add two images
        VipsSubtract (subtract), subtract two images
        [...]

It's a really long hierarchical list so you can display only a specific branch of it with vips -l class, class is in parenthesis in earlier example, e.g.:

vips -l conversion

VipsConversion (conversion), conversion operations
      VipsCopy (copy), copy an image
      VipsBlockCache (blockcache), cache an image
        VipsTileCache (tilecache), cache an image as a set of tiles
        VipsLineCache (linecache), cache an image as a set of lines
      VipsSequential (sequential), check sequential access
      VipsCache (cache), cache an image
   [...]

To learn how to use an operation run vips <operation> e.g.:

vips text

which prints:

make a text image
usage:
   text out text
where:
   out          - Output image, output VipsImage
   text         - Text to render, input gchararray
optional arguments:
   font         - Font to render with, input gchararray
   width        - Maximum image width in pixels, input gint
            default: 0
            min: 0, max: 10000000
   align        - Align on the low, centre or high edge, input VipsAlign
            default: low
            allowed: low, centre, high
   dpi          - DPI to render at, input gint
            default: 72
            min: 1, max: 1000000
   spacing      - Line spacing, input gint
            default: 0
            min: 0, max: 1000000

You can than use it like this to get a png image with your text:

vips text mytext.png "Text to show in the image"

which gives

mytext.png

You can convert it to JPG:

vips jpegsave mytext.png mytext.jpg

and back to PNG:

   vips pngsave mytext.jpg mytextconv.png

Resizing in vips means making a bigger image.

 vips resize mytext.png mytext2.png 2

The above example scales the input mytext.png by factor of 2 and outputs mytext2.png. If you want to downsize an image use shrink but in this case you have to include first horizontal and then vertical scale as the last argument:

vips shrink mytext.png mytext4.png 2 2

Hope this will get you going with vips. If you really feel intimidated by command line, you can use a graphical interface to vips called nip2, which deserves a separate post on its own.

Sort:  

How does it compares to image magic?

Vips seems to be the fastest program in this comparison, apparently ImageMagick is 4.1 times slower. But I saw benchmarks where it was 10 times slower than Vips.