libVIPS
a demand-driven, horizontally threaded image processing library. Compared to similar libraries, libvips runs quickly and uses little memory. - libVIPS / github / blog / wikipedia
- Automatic computation reordering
- support jpeg-xl since libvips 8.11 - but not as part as ubuntu release
Compiling
It straitghforward through meson. But it requires additional libraries to support features:
- libspng (recommended) - faster png operation
- otherwise use libpng
- mozjpeg (recommended) - compatible with the libjpeg API and ABI. It is intended to be a drop-in replacement for libjpeg. MozJPEG is a patch for libjpeg-turbo.
- libjpeg-turbo - a JPEG image codec that uses SIMD instructions to accelerate baseline JPEG compression and decompression
- libjpeg - fallback
- libjxl - for jpegxl
-
libwebp
- highway - SIMD support
- orc - Optimized Inner Loops Runtime Compiler
nip2
A user interface for libvips.
see also
- Difference Hash computation - use libvips for image shrinking - access band[0] direclty
- Color Quantisation - Color Quantisation CLI - direct pixels reading within region
Doc / c++ / SO
- Hello World
- How libvips opens a file
- Sequential mode read - Not all operations need random access to their source pixels. For example, thumbnailing, the process of shrinking images for display, can work strictly top-to-bottom. But this has re-reading constraint
- Fancy transforms
- Some newbie questions on how to do things with libvips
C++ API
The libvips C++ API is a thin layer over the libvips GObject API. It adds automatic reference counting, exceptions, operator overloads, and automatic constant expansion.
You can drop down to the C API at any point, so all the C API docs also work for C++.
- The API overloads () to be vips_getpoint() - which is very slow
- The API overloads [] to be vips_extract_band()
- VIPS images / c++
VIPS images are three-dimensional arrays, the dimensions being width, height and bands
- crop synonym for extract_area - Extract an area from an image.
- data - Arrange for the underlying object to be entirely in memory, then return a pointer to the first pixel.
see also
Iterating over Region
An image can be very large, much larger than the available memory, so you can’t just access pixels with a pointer *.
That will only work for 8-bit images, and I’ve not tried to handle errors or int overflow correctly. With a 10k x 10k pixel RGB JPEG I see: 700ms to decompress and scan a 300mb image, with a peak memory use of 150mb.
see also
Colors
- filters like sepia, black-white
- New colour package
- autodetect CMYK and convert to sRGB JPEG
- colour operators - These operators let you transform coordinates and images between colour spaces, calculate colour differences, and move to and from device spaces. - Use vips_colourspace() to move an image to a target colourspace using the best sequence of colour transform operations.
- Contrast-Limited Adaptive Histogram Equalisation
Image shrinking
- vips_thumbnail() - don’t use thumbnail_image on already loaded images. - Because the image has already been opened, it can’t do any of the shrink-on-load tricks that help make thumbnail fast.
- Making DeepZoom, Zoomify and Google Maps image pyramids with vips
- How to use libvips to shrink giant images with limited memory - not possible on progressive or interlaced image (like some jpegs).
Image arithmetic
Perform an arithmetic operation, such as addition, on every pixel in an image or a pair of images.
- vips_project - the sum of every row of pixels, and the sum of every column of pixels.
Defining Matrix
Internals
pyvips
Ruby
Full bindings are available for
Iterate over pixel
You can’t really iterate over pixels in libvips, since images don’t really exist. Everything is a delayed computation and pixels only exist on demand. You can either implement a new vips operation, or render the whole image to an area of memory and then treat it like any other array. Have a look at vips_image_write_to_memory().
For eg:
From version 8.4
before
Note: it is much faster to do that than accessing pixels through vips_getpoint()
VIPS History
background on its 30 years of development