color_palette_extractor 0.0.1
color_palette_extractor: ^0.0.1 copied to clipboard
Dart package + apps for color palette extraction
color_palette_extractor #
đ¨đŠâđ¨ Dart package + apps for color palette extraction
dart pub get color_palette_extractor
đ Use cases #
- đĒŠ Party lights: set party lighting to match music cover art (& animate to music tempo)
- đ¨ Art projects: match the ambient lighting to displayed artwork
- đĄ Home automation: use the bundled HTTP server to integrate color palette extraction into Home Assistant automations
⨠Features #
- Extracts dominant color palettes from images
- Configurable palette size
- Fast: 512x512 image processes in
75ms(tested on Apple M4) - Supports GIFs and multi-frame images
- Uses
OKLCHcolor space for accurate color representation - Discards transparent pixels
Coming up next
- Cleaner API: less reliance on custom color classes
- More configuration options for customizing the color extraction process
- Faster processing, aiming for realtime 60FPS on 512x512 images
- HTTP server example for interfacing with Home Assistant & etc.
đŽ Usage Guide #
Getting Started #
Install the package using Dart's package manager:
dart pub get color_palette_extractor
Just import the package in your Dart code and call the color extractor.
Use with the image package for handling image files.
import 'package:image/image.dart';
import 'package:color_palette_extractor/color_palette_extractor.dart';
...
final image = ...; // open file or decode from a Uint8List
final colors = extractPalette(image, paletteSize: 6);
The returned colors are using the OKLCH color space (see the oklch package). The palette uses a OKLCHColorX extension containing int frequency for each color. This allows you to know how dominant each color is within the extracted palette.
See the color_palette_ui example for usage of the color palette extractor in a UI context đŠĩ
đ License #
This project is licensed under the Mozilla Public License 2.0 - see the LICENSE file for details.
đĨ Contributing #
Contributions are welcome! Please open an issue or submit a pull request for any improvements or bug fixes. Make sure to read the following guidelines before contributing:
đ Credits & Acknowledgements #
Contributors đ§âđģđđ #
This package is developed/maintained by the following rockstars! Your contributions make a difference! đ
Sponsors đĢļâ¨đĨŗ #
Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! đ
Based on
dart_package_template- a high-quality Dart package template with best practices, CI/CD, and more! đâ¨