replace_palette 0.1.4 copy "replace_palette: ^0.1.4" to clipboard
replace_palette: ^0.1.4 copied to clipboard

Replaces the color palette in an image, respecting the color models. The easy-to-use and well-tested package.

example/main.dart

// ignore_for_file: avoid_print

import 'dart:io';

import 'package:image/image.dart';
import 'package:replace_palette/replace_palette.dart';
import 'package:uni_color_name/uni_color_name.dart';

/// Run:
/// ```
/// cd example
/// dart main.dart
/// ```
Future<void> main() async {
  const fileSource = 'colorful_swirl';
  const filesPalettes = ['black_white', 'faber_castell_36'];
  for (final fp in filesPalettes) {
    await dress(fileSource, fp);
  }
  print('✅ Files created in the `example` folder.');
}

Future<void> dress(String fileSource, String filePalette) async {
  final palette = UniPalette<int>.file(
    'palettes/$filePalette.json',
    ColorModel.rgb,
  );
  final image =
      await const Dresser().dressFile(File('data/$fileSource.webp'), palette);
  File('../_output/${fileSource}_$filePalette.png')
    ..createSync(recursive: true)
    ..writeAsBytesSync(encodePng(image));
}

Future<void> dressExample() async {
  final palette = UniPalette<int>.file('my_palette.json', ColorModel.rgb);
  final image = await const Dresser().dressFile(File('my_image.webp'), palette);
  File('my_result.png')
    ..createSync(recursive: true)
    ..writeAsBytesSync(encodePng(image));
}
3
likes
160
points
96
downloads
screenshot

Publisher

verified publishersyrokomskyi.com

Weekly Downloads

Replaces the color palette in an image, respecting the color models. The easy-to-use and well-tested package.

Repository (GitHub)
View/report issues
Contributing

Topics

#palette #color #replace #edit #image

Documentation

API reference

License

MIT (license)

Dependencies

image, uni_color_model, uni_color_name

More

Packages that depend on replace_palette