Flutter/Dart FFI bindings for libvips - a fast, multi-threaded image processing library.
- Image loading/saving (JPEG, PNG, WebP, TIFF, GIF, etc.)
- Image transformations (resize, rotate, crop, flip)
- Image filters (blur, sharpen, invert, gamma)
- Color space conversions
- Smart crop and gravity
- High performance with multi-threading support
┌─────────────────────────────────────────────────────────────────┐
│ Your Application │
├─────────────────────────────────────────────────────────────────┤
│ Flutter Mobile │ Flutter Desktop │ Pure Dart Desktop │
│ (Android/iOS) │ (macOS/Win/Linux) │ (CLI/Server) │
├────────────────────┼────────────────────┼───────────────────────┤
│ libvips_ffi │ libvips_ffi │ libvips_ffi_core │
│ (includes native) │ + platform pkg │ + loader choice │
└────────────────────┴────────────────────┴───────────────────────┘
│
┌───────────────┼───────────────┐
▼ ▼ ▼
libvips_ffi_macos libvips_ffi_windows libvips_ffi_linux
(pre-compiled) (pre-compiled) (pre-compiled)
│
▼
libvips_ffi_core (Pure Dart FFI)
This project uses melos for multi-package management.
| Package | Description |
|---|---|
| libvips_ffi_core | Pure Dart FFI bindings (no Flutter dependency) |
| Package | Description |
|---|---|
| libvips_ffi | Flutter mobile (Android/iOS) with bundled native libraries |
| libvips_ffi_macos | Pre-compiled libvips for macOS (arm64 + x86_64) |
| libvips_ffi_windows | Pre-compiled libvips for Windows (x64) |
| libvips_ffi_linux | Pre-compiled libvips for Linux (x64) |
| libvips_ffi_desktop | Desktop meta package (auto-selects platform) |
| Package | Description |
|---|---|
| libvips_ffi_system | Load from system package manager (Homebrew, apt, etc.) |
| libvips_ffi_loader | Dynamic library downloader with callback support |
Pre-compiled native libraries are bundled automatically.
dependencies:
libvips_ffi: ^0.0.1import 'package:libvips_ffi/libvips_ffi.dart';
void main() {
initVips();
// Sync API with VipsPipeline (fluent chainable)
final pipeline = VipsPipeline.fromFile('input.jpg');
pipeline.resize(0.5);
pipeline.toFile('output.jpg');
pipeline.dispose();
// Async API (recommended for Flutter UI)
final result = await VipsCompute.resizeFile('input.jpg', 0.5);
// result.data contains processed image bytes
shutdownVips();
}Use libvips_ffi with platform-specific packages for bundled libraries.
dependencies:
libvips_ffi: ^0.0.1
libvips_ffi_macos: ^0.1.0 # macOS
# libvips_ffi_windows: ^0.1.0 # Windows
# libvips_ffi_linux: ^0.1.0 # Linuximport 'package:libvips_ffi/libvips_ffi.dart';
void main() {
initVips(); // Auto-detects platform and loads bundled library
// Same API as mobile
final result = await VipsCompute.resizeFile('input.jpg', 0.5);
shutdownVips();
}For non-Flutter Dart applications.
dependencies:
libvips_ffi_core: ^0.1.0import 'package:libvips_ffi_core/libvips_ffi_core.dart';
void main() {
// Requires: brew install vips (macOS) or apt install libvips-dev (Linux)
initVipsSystem();
final pipeline = VipsPipeline.fromFile('input.jpg');
pipeline.resize(0.5);
pipeline.toFile('output.jpg');
pipeline.dispose();
shutdownVips();
}dependencies:
libvips_ffi_desktop: ^0.1.0import 'package:libvips_ffi_desktop/libvips_ffi_desktop.dart';
void main() {
initVipsDesktop(); // Auto-selects platform
// ...
shutdownVips();
}| Scenario | Recommended Package(s) |
|---|---|
| Flutter mobile app | libvips_ffi |
| Flutter desktop app | libvips_ffi + libvips_ffi_<platform> |
| Dart CLI tool (system libvips) | libvips_ffi_core |
| Dart CLI tool (bundled libvips) | libvips_ffi_desktop |
| Custom library loading | libvips_ffi_core + libvips_ffi_loader |
| API | Use Case | Blocks UI? |
|---|---|---|
VipsPipeline (sync) |
Simple scripts, CLI tools | Yes |
VipsPipelineCompute (async) |
Flutter apps, UI-heavy apps | No (runs in isolate) |
// Sync - blocks until complete
final pipeline = VipsPipeline.fromFile('input.jpg');
pipeline.resize(0.5).blur(2.0);
pipeline.toFile('output.jpg');
pipeline.dispose();
// Async - runs in background isolate
final result = await VipsPipelineCompute.processFile(
'input.jpg',
(p) => p.resize(0.5).blur(2.0),
);- Packages with pre-compiled binaries:
x.y.z+libvips_version- Example:
0.1.0+8.16.0means package version 0.1.0 with libvips 8.16.0
- Example:
- Pure Dart packages:
x.y.z
- Dart SDK >= 3.5.0
- Flutter >= 3.0.0 (for Flutter packages)
# Install melos
dart pub global activate melos
# Bootstrap all packages
melos bootstrap
# Run analysis
melos analyze
# Run tests
melos testLGPL-2.1 - see LICENSE for details.