dart_lut 0.0.4

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 48

Dart LUT3D #

pub package Build Status

The library for working with LUTs.

License #

project under MIT license

Changelogs #

full changelog

Task List #

  • [x] Basic impl.
  • [x] Read .cube files
  • [ ] Read another formats
  • [x] Store 3DLUT
  • [ ] Generate LUTs by expression
  • [x] Verifying LUTs
  • [x] Applying 3D LUTs
  • [ ] Applying 1D LUTs
  • [ ] Optimize perfomance
  • [x] Trilinear interpolation
  • [x] More tests
  • [ ] Documentation
  • [x] Publish to PUB
  • [ ] Remove task list

0.0.4 #

  • more tests
  • fixed wrong equalification of Colour class
  • error handling while parsing LUT
  • added travis integration
  • some minor changes

Instalation #

add dependency in pubsec.yaml

from pub.dartlang.org:

dependencies:
  dart_lut: ^0.0.4

latest from github.com:

dependencies:
  dart_lut:
      git: git://github.com/NiKoTron/dart-lut.git

Usage #

generic example:

import 'dart:io';

import 'package:image/image.dart';
import 'package:dart_lut/src/lut.dart';
final lut = LUT.fromString(File('example.cube').readAsStringSync());
final isLoaded = await lut
    .awaitLoading()
    .timeout(Duration(milliseconds: 1500), onTimeout: () => false);

if (isLoaded) {
  final image = decodeImage(imageFile.readAsBytesSync());
  var lutedBytes = lut.applySync(image.getBytes());

  var imageLUT = Image.fromBytes(image.width, image.height, lutedBytes);
  var outputFile = File('out.jpg')..writeAsBytesSync(encodeJpg(imageLUT));
}
lut.applyAsStream(image.getBytes()).listen((result) {
  print('#${result.toRadixString(16).padLeft(4, '0')}'); //print ARGB value after applying LUT in HEX format
});

Sample results #

Photo by Caique Silva on Unsplash

image by Caique Silva LUTs: KURO B&W by David Morgan Jones, Arabica 12 and Lenox 340 by rocketstock

Photo by sean Kong on Unsplash

image by sean Kong LUTs: KURO B&W by David Morgan Jones, Arabica 12 and Lenox 340 by rocketstock

CHANGELOG #

0.0.1 #

  • initial release

0.0.2 #

  • remove .fromFile(File f) factory

0.0.3 #

  • added stream output

0.0.4 #

  • more tests
  • fixed wrong equalification of Colour class
  • error handling while parsing LUT
  • added travis integration
  • some minor changes

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) async {
  final parser = ArgParser()
    ..addOption('lut-file', abbr: 'l')
    ..addOption('in-img', abbr: 'i')
    ..addOption('out-dir', abbr: 'o', defaultsTo: './out');

  _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 {
      final image = decodeImage(imageFile.readAsBytesSync());
      final sw = Stopwatch()..start();
      final interp = InterpolationType.trilinear;

      final v = lut.applySync(image.getBytes(), interp);

      print('lut apply in ${sw.elapsed}');
      sw.stop();
      final image2 = Image.fromBytes(image.width, image.height, v);
      final 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}');
    });
  }
}

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

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

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

    final isLoaded = await lut.awaitLoading();
    if (isLoaded) {
      final image = decodeImage(imageFile.readAsBytesSync());
      final interp = InterpolationType.trilinear;
      lut.applyAsStream(image.getBytes(), interp).listen((result) {
        //print('#${result.toRadixString(16).padLeft(4, '0')}');
      });
    }
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  dart_lut: ^0.0.4

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:dart_lut/dart_lut.dart';
  
Version Uploaded Documentation Archive
0.0.4 Dec 26, 2018 Go to the documentation of dart_lut 0.0.4 Download dart_lut 0.0.4 archive
0.0.3 Dec 19, 2018 Go to the documentation of dart_lut 0.0.3 Download dart_lut 0.0.3 archive
0.0.2 Dec 18, 2018 Go to the documentation of dart_lut 0.0.2 Download dart_lut 0.0.2 archive
0.0.1 Dec 17, 2018 Go to the documentation of dart_lut 0.0.1 Download dart_lut 0.0.1 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
48
Learn more about scoring.

We analyzed this package on Apr 12, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.2.0
  • pana: 0.12.14

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:dart_lut/dart_lut.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
Dev dependencies
args ^1.5.1
image ^2.0.4
path ^1.6.2
test ^1.3.0