LoginSignup
1
1

More than 5 years have passed since last update.

PixelPicker::ColorName の紹介

Last updated at Posted at 2016-04-21

PixelPicker::ColorName の紹介

Ruby の練習がてら RubyGem を作成してみました。

この Gem は画像ファイルを渡すと、その画像に含まれる色名を返してくれます。
また、カラーパレットを取得するオプションも有ります。

例えば、大量の画像ファイルを色名で分類したい時などに便利です。

使いかた

コマンドラインからは以下のようにファイル名を渡してあげると、色名(文字列)が返ります。

例えば、次のような画像を渡すと、以下の様な結果が返ります。

$ bin/color_name ~/Pictures/car_logo.png
blue

また、 Ruby インターフェースも提供しており、こちらからであればカラーパレットの
取得もできます。

$ bin/console
irb(main):001:0> pixel = PixelPicker::ColorName.new('/Users/foobar/Pictures/car_logo.png')
=> #<PixelPicker::ColorName:0x007fa791c7ba60 @image_file="/Users/foobar/Pictures/car_logo.png">
irb(main):002:0> pixel.palette
=> {:orange=>20331, :yellow=>28495, :red=>1030573, :blue=>1379614, :aqua=>1479, :violet=>450, :purple=>1882, :green=>476, :lime=>102}

詳しくは、README をご覧くださいませ。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1