Project

huespace

0.0
No release in over a year
Huespace can extract a color palette from local images, url-s or images as byte-streams. Besides palettes, it can also extract the most dominant color and the most colorful color!
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 3.2

Runtime

~> 4.11.0
 Project Readme

Huespace

A ruby gem that extracts a palette of most representative colors from images.

Inspired by color-thief by Lokesh Dhakar (https://github.com/lokesh/color-thief) and Camalian by Nazar Hussain (https://github.com/nazarhussain/camalian/blob/master/camalian.gemspec)

Installation

Install the gem and add to the application's Gemfile by executing:

$ bundle add huespace

If bundler is not being used to manage dependencies, install the gem by executing:

$ gem install huespace

Usage

image_source

In the following text image_source means one of the following:

  • path to the image stored locally
  • url of the image
  • image as a stream of bytes (so you can fetch it once on the backend)

Extracting a palette of colors

Returns an array of colors, exp. [[47, 48, 62], [91, 92, 117], [218, 154, 95]]

Huespace.get_palette(image_source, n_colors)

Extracting the dominant color

Returns the color that best represents the image

Huespace.get_dominant_color(image_source)

Extracting the most colorful color

Returns the most colorful (probably best described as most vibrant) color from a palette of 6 colors

Huespace.get_most_colorful_color(image_source)

License

The gem is available as open source under the terms of the MIT License.