Skip to main content

libvips_ffi_api

High-level Dart API for libvips image processing.

Installation

dependencies:
libvips_ffi_api: ^0.1.0+8.16.0
note

This package does not include libvips binaries. You also need a loader package (libvips_ffi, libvips_ffi_desktop, or libvips_ffi_system).

Features

  • VipsPipeline - Fluent chainable API
  • PipelineSpec - Serializable pipeline definitions
  • Complete FFI bindings for libvips operations
  • Type-safe operation parameters

Core Classes

VipsPipeline

The main class for image processing with a fluent API.

final result = VipsPipeline.fromFile('input.jpg')
.resize(width: 800)
.gaussianBlur(sigma: 1.5)
.toJpeg(quality: 85);

PipelineSpec

A serializable specification for pipeline operations.

final spec = PipelineSpec.fromFile('input.jpg')
.resize(width: 800)
.toJpeg(quality: 85);

// Execute synchronously
final result = spec.execute();

// Or save for later / send to isolate
final json = spec.toJson();

VipsImg

Low-level image wrapper for direct FFI operations.

final img = VipsImg.fromFile('input.jpg');
try {
// Direct access to image properties
print('Width: ${img.width}');
print('Height: ${img.height}');
print('Bands: ${img.bands}');
} finally {
img.dispose();
}

Bindings

The package includes complete FFI bindings organized by category:

ModuleOperations
ArithmeticBindingsadd, subtract, multiply, divide, clamp, etc.
ColourBindingscolourspace, icc_import, icc_export, etc.
ConversionBindingscast, flip, rot, embed, extract, etc.
ConvolutionBindingsconv, sharpen, gaussblur, etc.
CreateBindingsblack, xyz, text, gaussnoise, etc.
DrawBindingsdraw_rect, draw_circle, draw_line, etc.
IoBindingsload, save (jpeg, png, webp, etc.)
ResampleBindingsresize, thumbnail, affine, etc.

Extension Methods

Operations are organized as extension methods on VipsPipeline:

// Arithmetic extensions
pipeline.add(value)
pipeline.multiply(factor)
pipeline.clamp(min, max)

// Colour extensions
pipeline.grayscale()
pipeline.colourspace(VipsInterpretation.sRGB)

// Geometry extensions
pipeline.resize(width: 800)
pipeline.rotate(angle: 45)
pipeline.crop(x: 0, y: 0, width: 100, height: 100)

// Filter extensions
pipeline.gaussianBlur(sigma: 2.0)
pipeline.sharpen()

Error Handling

try {
final result = VipsPipeline.fromFile('input.jpg')
.resize(width: 800)
.toJpeg();
} on VipsApiException catch (e) {
print('libvips error: ${e.message}');
}