Sequential access: VIPS Reference Manual

## Sequential access

This a fairly recent addition to libvips and is a hybrid of the previous two.

Imagine how this command might be executed:

    $ vips flip fred.jpg jim.jpg vertical

meaning, read `fred.jpg`, flip it up-down, and write as `jim.jpg`.

In order to write `jim.jpg` top-to-bottom, it’ll have to read `fred.jpg` bottom-to-top. Unfortunately libjpeg only supports top-to-bottom reading and writing, so libvips must convert `fred.jpg` to a random access format before it can run the flip operation.

However many useful operations do not require true random access. For example:

    $ vips shrink fred.png jim.png 10 10

meaning shrink `fred.png` by a factor of 10 in both axes and write as `jim.png`.

You can imagine this operation running without needing `fred.png` to be completely decompressed first. You just read 10 lines from `fred.png` for every one line you write to `jim.png`.

To help in this case, libvips has a hint you can give to loaders to say “I will only need pixels from this image in top-to-bottom order”. With this hint set, libvips will hook up the pipeline of operations directly to the read-a-line interface provided by the image library, and add a small cache of the most recent 100 or so lines.

This is done automatically in command-line operation. In programs, you need to set `access` to VIPS_ACCESS_SEQUENTIAL in calls to functions like `vips_image_new_from_file()`.