Search packages, repositories and app categories

Package detailsv1.0.2

color_thief_flutter

Grab the color palette from an image, the Flutter implementation of color-thief.

30-day downloads
65
Likes
37
Pub points
40

Install package

flutter pub add color_thief_flutter

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Color Thief Flutter is a Flutter package that extracts dominant colors from images, providing a color palette based on the most prominent hues. It's a Dart implementation of the popular Color Thief algorithm, enabling developers to analyze and utilize image colors in their apps. The package works by sampling pixels from an image and clustering similar colors to generate a representative palette. Ideal for dynamic UIs, theme generation, or visual design tools, it supports efficient color extraction with minimal overhead. The source code is open and available on GitHub for transparency and contribution.

Use cases

  • Dynamic theme generation
  • UI color extraction from images
  • Visual design tools
  • Image-based color palettes
  • App background color matching

Key features

  • Extracts dominant colors from images
  • Uses color clustering algorithm
  • Lightweight and efficient
  • Open-source with GitHub access
  • Supports Flutter platforms

Suitable for

  • Design-focused applications
  • Image processing features
  • Theme customization tools
  • Creative app development
  • Mobile UI enhancements

Considerations

  • Requires image loading before color extraction
  • Limited to dominant color analysis
  • No real-time processing support
  • Depends on external image data
  • May vary results based on image size

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

color_thief_flutter

the Flutter implementation of color-thief, based on quantize_dart.

Usage

import 'package:color_thief_flutter/color_thief_flutter.dart';
import 'package:color_thief_flutter/utils.dart';

// color_thief_flutter.dart

getColorFromUrl('url/to/image').then((color) {
  print(color); // [R,G,B]
});

getPaletteFromUrl('url/to/image').then((palette) {
  print(palette); // [[R,G,B]]
});

getImageFromUrl('url/to/image').then((image) {
  print(image); // Image
});

getImageFromProvider(imageProvider).then((image) {
  print(image); // Image
});

getColorFromImage(image).then((color) {
  print(color); // [R,G,B]
});

getPaletteFromImage(image).then((palette) {
  print(palette); // [[R,G,B]]
});

// utils.dart

final hsv = fromRGBtoHSV([90, 90, 90]);
print(hsv); // [0, 0, 35]

final rgb = fromHSVtoRGB([90, 90, 90]);
print(rgb); // [126, 230, 23]
color_thief_flutter.dart

Main package of color_thief_flutter.

All these functions return null if the parameter is unqualified

getColorFromUrl(String url, [int quality])

returns the base color from the largest cluster, represented as [R,G,B]

getPaletteFromUrl(String url, [int colorCount, int quality])

returns a list that contains the reduced color palette, represented as [[R,G,B]]

getImageFromUrl(String url)

returns the Image from url

getImageFromProvider(ImageProvider imageProvider)

returns the real Image of ImageProvider

getColorFromImage(Image image, [int quality = 10])

returns the base color from the largest cluster, represented as [R,G,B]

getPaletteFromImage(Image image, [int colorCount, int quality])

returns a list that contains the reduced color palette, represented as [[R,G,B]]

parameters
  • url - Url to image.
  • imageProvider - ImageProvider.
  • image - Image that get from getImageFromProvider.
  • colorCount - Between 2 and 256. The maximum number of colours allowed in the reduced palette.
  • quality - Between 1 and 10. There is a trade-off between quality and speed. The bigger the number, the faster the palette generation but the greater the likelihood that colors will be missed.
utils.dart

Tools for format colors.

May cause loss of significance

fromRGBtoHSV(List list)

retruns HSVColor, represented as [H,S,V]

fromHSVtoRGB(List list)

retruns RGBColor, represented as [R,G,B]

parameters
  • R,G,B's range is [0,255]
  • H's range is [0,360]
  • S,V's range is [0,100]

License

Licensed under the MIT License.

Categories

Dependencies

Dependency list 1 items

  • quantize_dart^1.0.3

Source repository

Projects using this package

No data available yet.