Skip to main content

color_palette_extractor 0.0.1 copy "color_palette_extractor: ^0.0.1" to clipboard
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

License: MPL 2.0 build example stars
pub package pub score likes

💙 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 OKLCH color 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! 💖

contributors badge

Sponsors đŸĢļ✨đŸĨŗ #

Kind thanks to all our sponsors! Thank you for supporting the Dart/Flutter community, and keeping open source alive! 💙

sponsors badge


Based on dart_package_template - a high-quality Dart package template with best practices, CI/CD, and more! 💙✨

0
likes
140
points
69
downloads

Documentation

API reference

Publisher

verified publisherkerberjg.dev

Weekly Downloads

Dart package + apps for color palette extraction

Repository (GitHub)
View/report issues
Contributing

License

MPL-2.0 (license)

Dependencies

image, oklch

More

Packages that depend on color_palette_extractor