image_pipeline 0.0.1 copy "image_pipeline: ^0.0.1" to clipboard
image_pipeline: ^0.0.1 copied to clipboard

An efficient, cross-platform image processing library for Dart that delegates tasks to highly optimized native libraries.

example/main.dart

// ignore_for_file: avoid_print just for demo

import 'dart:io';
import 'dart:typed_data';
import 'package:image_pipeline/image_pipeline.dart';
import 'package:path/path.dart' as path;

const _sampleImagePaths = ['assets', 'sample', 'sample_jpeg.jpeg'];
const _sampleOutputImagePath = 'example/transformed_sample';

void main() async {
  final inputBytes = await _getFileOrThrow();

  try {
    print('Transforming image...');
    final result = await ImageTransformer.native().transform(inputBytes, [
      const ResizeOp(maxWidth: 1920, maxHeight: 1920),
      const QualityOp(quality: 80),
    ]);

    final outputFile = File('$_sampleOutputImagePath.${result.extension}');
    await outputFile.writeAsBytes(result.bytes);

    print('Transformation complete! Saved to: ${outputFile.path}');
  } catch (e, s) {
    print('An error occurred during transformation: $e\n\n$s');
  } finally {
    print('Shutting down engine...');
    await ImageTransformer.terminate();
  }
}

Future<Uint8List> _getFileOrThrow() async {
  final inputFile = File(
    path.joinAll([path.current, ..._sampleImagePaths]),
  );
  if (!inputFile.existsSync()) {
    throw Exception('Error: ${inputFile.path} not found.');
  }
  return inputFile.readAsBytes();
}
0
likes
160
points
136
downloads

Documentation

API reference

Publisher

verified publishermattiapispisa.it

Weekly Downloads

An efficient, cross-platform image processing library for Dart that delegates tasks to highly optimized native libraries.

Homepage
Repository (GitHub)
View/report issues

Topics

#image #processing #pipeline

License

BSD-3-Clause (license)

Dependencies

archive, code_assets, en_logger, ffi, hooks, http, mime, native_toolchain_c, path

More

Packages that depend on image_pipeline