Skip to content

adamazing/colorbuddy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

59 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🎨 Welcome to Color Buddy 🎨

Free Palestine 🍉🇵🇸 Version License: MIT

Color Buddy is a command line tool that can generate a color palette from an image.

Contents

Install

cargo install colorbuddy

Usage

colorbuddy --help

Produces the following output:

Generates a color palette based on an image.

Usage: colorbuddy [OPTIONS] <IMAGE>

Arguments:
  <IMAGE>

Options:
  -m, --quantisation-method <QUANTISATION_METHOD>
          [default: k-means] [possible values: median-cut, k-means]
  -n, --number-of-colors <NUMBER_OF_COLORS>
          [default: 8]
  -o, --output <OUTPUT>

  -t, --output-type <OUTPUT_TYPE>
          [default: original-image] [possible values: json, original-image, standalone-palette]
  -p, --palette-height <PALETTE_HEIGHT>
          [default: 256]
  -w, --palette-width <PALETTE_WIDTH>

  -h, --help
          Print help information
  -V, --version
          Print version information

Examples

The default options will result in:

  • a copy of the original image being output with a palette of
  • 8 colors along the bottom
  • with a height of 256px
  • calculated using k-means clustering

Generate JSON containing the 8 most prevalent colors in the image:

colorbuddy --output-type json original-image.jpg

Output the original images with a palette of the 5 most prevalent colors along the bottom:

colorbuddy --number-of-colors 5 --output-type original-image.jpg another-image.jpg

Specify the height of the palette as a percentage of the original image's height:

colorbuddy --palette-height 20% original-image.jpg

Specify a width, height, and the standalone-palette output height to create a standalone palette image:

colorbuddy --palette-height 50px --palette-width 500 original-image.jpg

FAQs

Q. What is Median Cut Quantisation?

Median Cut quantization is a method used in image processing to reduce the number of colors used in an image. The goal is to represent the original image using a smaller color palette, while preserving as much of the visual information as possible.

Think of it like this: imagine you have a box of crayons, and you want to reduce the number of crayons you have while still being able to color a picture. The Median Cut quantization method would help you choose a smaller set of crayons that represent the range of colors used in your picture, so that you can still color a picture that looks similar to the original.

In Median Cut quantization, the first step is to divide the color space of the image into smaller sections. This is done by finding the median color value in each section and dividing the section in two based on this median value. This process is repeated until you have the desired number of colors in your palette.

Q. What is "k-means clustering"?

K-means clustering is a machine learning technique used for grouping data into "clusters" based on similarities between the data points.

Think of it like this: imagine you have a bunch of different colored balls, and you want to group them into a few different baskets based on their color. K Means Clustering is a way for the computer to automatically separate the balls into baskets such that each basket contains balls of similar color.

The "K" in K Means refers to the number of baskets you want to create. So, you can choose to have 2 baskets, 3 baskets, or even 10 baskets, depending on how many groups you want to create.

Q. What is the difference between the two quantisation methods?

Or: "When should I use one method over the other?"

K-means clustering results in a palette of the most common colours in the image, whereas median cut quantisation results in a palette of representative colours.

Experiment with what works best for your application!

Help

This is a personal, unpaid, open source project. If you encounter a bug or other issue, require help or the addition of some new feature, please feel free to raise an Issue on GitHub. I will endeavour to respond in a relatively timely manner but provide no guarantees.

Roadmap

  • Allow users to generate palette information used by their graphics tools/applications
  • Refactor and pay down technical debt
  • Allow users to generate a separate standalone palette image
  • Allow users to specify multiple images upon which to apply the same options
  • Allow users to specify an output file/directory
  • Add tests

Author

👨 Adam Henley (he/him)

Show your support

Give a ⭐️ if this project helped you!

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published

Languages