libvips_ffi_loader 0.1.0+8.16.0 copy "libvips_ffi_loader: ^0.1.0+8.16.0" to clipboard
libvips_ffi_loader: ^0.1.0+8.16.0 copied to clipboard

Dynamic library loader for libvips_ffi with callback-based download support.

libvips_ffi_loader #

Dynamic library loader for libvips_ffi with callback-based download support.

Features #

  • Download libvips binaries on demand
  • Callback-based progress reporting
  • Platform-specific library management

Usage #

import 'package:libvips_ffi_loader/libvips_ffi_loader.dart';

import 'dart:io';

void main() async {
  await VipsLoader.init(
    provider: (request) async {
      final cacheDir = request.suggestedCacheDir;
      final libPath = '$cacheDir/${request.libraryFileName}';

      if (await File(libPath).exists()) {
        return libPath;
      }

      final zipPath = '$cacheDir/libvips.zip';
      final url = 'https://your-cdn.example.com/libvips/'
          '${request.platformArchIdentifier}/'
          '${request.recommendedVersion}/'
          'libvips.zip';

      // Download zip (placeholder; implement your own HTTP client / retry / checksum).
      await downloadToFile(url: url, to: zipPath);

      // Extract zip into cacheDir (placeholder; implement your own unzip logic).
      // Make sure the extracted files include request.libraryFileName.
      await extractZip(zipPath: zipPath, toDir: cacheDir);

      return libPath;
    },
    onStateChanged: (state) {
      // checking/downloading/extracting/loading/ready/error
      print('libvips loading: $state');
    },
  );

  // After init, use VipsPipeline from libvips_ffi_api
  final pipeline = VipsPipeline.fromFile('input.jpg');
  pipeline.resize(0.5);
  pipeline.toFile('output.jpg');
  pipeline.dispose();
}

Download & Extract Notes #

The provider callback must return an absolute path to the final dynamic library:

  • Windows: libvips-42.dll
  • macOS: libvips.dylib
  • Linux: libvips.so.42

Use request.libraryFileName to avoid hardcoding.

Windows (example package suggestion) #

If you only need FFI calls, a practical source of prebuilt runtime DLLs is the vips-dev-w64-web-<version>.zip asset from:

https://github.com/libvips/build-win64-mxe/releases

When you package your zip for download, ensure libvips-42.dll and its dependent DLLs are placed together (typically in the same extracted directory).

0
likes
130
points
--
downloads

Publisher

unverified uploader

Weekly Downloads

Dynamic library loader for libvips_ffi with callback-based download support.

Repository (GitHub)
View/report issues

Topics

#image #image-processing #ffi #libvips #dynamic-loading

Documentation

API reference

License

unknown (license)

Dependencies

libvips_ffi_core, path

More

Packages that depend on libvips_ffi_loader