dart_lut 0.0.2 copy "dart_lut: ^0.0.2" to clipboard
dart_lut: ^0.0.2 copied to clipboard

outdated

The implementation of image processing via 3D LUT (LookUp Tables), so in familiar words - colour filters. It's written on the pure Dart language so that it can be used with Flutter, CLI and web.

example/main.dart

import 'dart:io';

import 'package:dart_lut/src/lut.dart';
import 'package:image/image.dart';
import 'package:args/args.dart';
import 'package:path/path.dart' as path;

void main(List<String> args) {
  final parser = ArgParser()
    ..addOption('lut-file', abbr: 'l', allowMultiple: false)
    ..addOption('in-img', abbr: 'i', allowMultiple: true)
    ..addOption('out-dir',
        abbr: 'o', defaultsTo: './out', allowMultiple: false);

  _run(parser.parse(args));
}

void _run(final ArgResults argResult) {
  for (var img in argResult['in-img']) {
    final imageFile = File(img);

    final lutFile = File(argResult['lut-file']);

    final lut = LUT.fromString(lutFile.readAsStringSync());

    lut.isLoaded.listen((data) async {
      Image image = decodeImage(imageFile.readAsBytesSync());
      final sw = Stopwatch()..start();
      var interp = InterpolationType.trilinear;
      var v = lut.applySync(image.getBytes(), interp);

      print('lut apply in ${sw.elapsed}');
      sw.stop();
      var image2 = Image.fromBytes(image.width, image.height, v);
      var outputFile = new File(
          '${argResult['out-dir']}/${path.basename(imageFile.path)}_${path.basename(lutFile.path)}_$interp.jpg')
        ..writeAsBytesSync(encodeJpg(image2));
      print('output image write to: ${outputFile.path}');
    });
  }
}
9
likes
0
pub points
12%
popularity

Publisher

verified publisherdart.tools

The implementation of image processing via 3D LUT (LookUp Tables), so in familiar words - colour filters. It's written on the pure Dart language so that it can be used with Flutter, CLI and web.

Repository (GitHub)
View/report issues

License

unknown (license)

More

Packages that depend on dart_lut