Miro
Extract the dominant colors from an image.
Feedback
Questions, Comments, Concerns, or Bugs?
GitHub Issues For All!
Installation
Add this line to your application's Gemfile:
gem 'miro'
And then execute:
$ bundle
Or install it yourself as:
$ gem install miro
Usage
Configuration
Miro.options
Miro.options[:image_magick_path] = '/usr/local/bin/convert'
Miro.options[:resolution] = '100x100'
Miro.options[:color_count] = 4
Miro.options[:method] = 'histogram'
By default the method option is configured with 'pixel_group' to improve performance change to 'histogram', this will fetch directly from imagemagick the image histogram without any disk operation(read/write) but read the original file.
Initializing an image
colors = Miro::DominantColors.new('/path/to/local/image.jpg')
colors = Miro::DominantColors.new('http://domain.com/path/to/image.jpg')
Retrieving colors from an image
colors.to_hex
colors.to_rgb
colors.to_rgba
Additional methods only available when histogram method is enabled
colors.to_hsl
colors.to_cmyk
colors.to_yiq
Retrieving percentages of colors disabled on histogram method
colors.by_percentage
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Added some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
License
Copyright 2012 Jon Buda. This is free software, and may be redistributed under the terms specified in the LICENSE file.