colordom 0.8.0-x86_64-linux
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CODE_OF_CONDUCT.md +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +53 -0
- data/lib/colordom/2.6/colordom.so +0 -0
- data/lib/colordom/2.7/colordom.so +0 -0
- data/lib/colordom/3.0/colordom.so +0 -0
- data/lib/colordom/3.1/colordom.so +0 -0
- data/lib/colordom/3.2/colordom.so +0 -0
- data/lib/colordom/color.rb +49 -0
- data/lib/colordom/error.rb +6 -0
- data/lib/colordom/image.rb +27 -0
- data/lib/colordom/version.rb +5 -0
- data/lib/colordom.rb +52 -0
- metadata +102 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: f4ad77aa114ee000cba996bd9f8b2f6c03b9c90a51b1abd27d2b23a357a57cbf
|
4
|
+
data.tar.gz: 8634b6159db5fca34d1e339c5567a488f87fbcdc6c3a33bc4ecec8ac21d175cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 748820d4d341bb738f08b4b822dadb27aad560e2ccb9fe86e1d8837a3d7d0c375eb1a0fe453225e967981f379b4615ca9f63b907ebea74e720cc9219fa5c9157
|
7
|
+
data.tar.gz: 1a6f0886b944164a991b1084d0e4435570e73564d3e99cae416e736130b27bada6e4bee4bcd8751689e07cd9dc555df17e13ee36032e756ceac9a8fae7731573
|
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# Code of Conduct
|
2
|
+
|
3
|
+
All participants of this project are expected to abide by our Code of Conduct, both online and during in-person events that are hosted and/or associated with this project.
|
4
|
+
|
5
|
+
## The Pledge
|
6
|
+
|
7
|
+
In the interest of fostering an open and welcoming environment, we pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
|
8
|
+
|
9
|
+
## The Standards
|
10
|
+
|
11
|
+
Examples of behavior that contributes to creating a positive environment include:
|
12
|
+
|
13
|
+
* Using welcoming and inclusive language
|
14
|
+
* Being respectful of differing viewpoints and experiences
|
15
|
+
* Referring to people by their preferred pronouns and using gender-neutral pronouns when uncertain
|
16
|
+
* Gracefully accepting constructive criticism
|
17
|
+
* Focusing on what is best for the community
|
18
|
+
* Showing empathy towards other community members
|
19
|
+
|
20
|
+
Examples of unacceptable behavior by participants include:
|
21
|
+
|
22
|
+
* The use of sexualized language or imagery and unwelcome sexual attention or advances
|
23
|
+
* Trolling, insulting/derogatory comments, and personal or political attacks
|
24
|
+
* Public or private harassment
|
25
|
+
* Publishing others' private information, such as a physical or electronic address, without explicit permission
|
26
|
+
* Other conduct which could reasonably be considered inappropriate in a professional setting
|
27
|
+
* Dismissing or attacking inclusion-oriented requests
|
28
|
+
|
29
|
+
## Enforcement
|
30
|
+
|
31
|
+
Violations of the Code of Conduct may be reported by sending an email to info@hardpixel.eu. All reports will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. Further details of specific enforcement policies may be posted separately.
|
32
|
+
|
33
|
+
We hold the right and responsibility to remove comments or other contributions that are not aligned to this Code of Conduct, or to suspend temporarily or permanently any members for other behaviors that are inappropriate, threatening, offensive, or harmful.
|
34
|
+
|
35
|
+
## Attribution
|
36
|
+
|
37
|
+
This Code of Conduct is adapted from [dev.to](https://dev.to/code-of-conduct).
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 jonian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
# Colordom
|
2
|
+
|
3
|
+
Ruby gem to extract dominant colors from images using native extension implemented in Rust. Rust must be available on your system to install this gem.
|
4
|
+
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/colordom.svg)](https://badge.fury.io/rb/colordom)
|
6
|
+
[![Build](https://github.com/hardpixel/colordom/actions/workflows/build.yml/badge.svg)](https://github.com/hardpixel/colordom/actions/workflows/build.yml)
|
7
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/6040c6d79abf2d6e7efb/maintainability)](https://codeclimate.com/github/hardpixel/colordom/maintainability)
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'colordom'
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle install
|
20
|
+
|
21
|
+
Or install it yourself as:
|
22
|
+
|
23
|
+
$ gem install colordom
|
24
|
+
|
25
|
+
## Usage
|
26
|
+
|
27
|
+
```ruby
|
28
|
+
require 'colordom'
|
29
|
+
|
30
|
+
# Get colors using histogram algorithm
|
31
|
+
Colordom.histogram(image_path)
|
32
|
+
|
33
|
+
# Get colors using median cut algorithm
|
34
|
+
Colordom.mediancut(image_path)
|
35
|
+
|
36
|
+
# Get colors using kmeans algorithm
|
37
|
+
Colordom.kmeans(image_path)
|
38
|
+
```
|
39
|
+
|
40
|
+
## Development
|
41
|
+
|
42
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
43
|
+
|
44
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
45
|
+
|
46
|
+
## Contributing
|
47
|
+
|
48
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hardpixel/colordom.
|
49
|
+
|
50
|
+
|
51
|
+
## License
|
52
|
+
|
53
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Colordom
|
4
|
+
# Color object with RGB and HEX values implemented in Rust.
|
5
|
+
class Color
|
6
|
+
# @!method initialize(r, g, b)
|
7
|
+
# A new instance of Color.
|
8
|
+
# @return [Color]
|
9
|
+
|
10
|
+
# @!attribute [r] r
|
11
|
+
# Red color value.
|
12
|
+
# @return [Integer]
|
13
|
+
|
14
|
+
# @!attribute [r] g
|
15
|
+
# Green color value.
|
16
|
+
# @return [Integer]
|
17
|
+
|
18
|
+
# @!attribute [r] b
|
19
|
+
# Blue color value.
|
20
|
+
# @return [Integer]
|
21
|
+
|
22
|
+
# @!method rgb
|
23
|
+
# @!parse [ruby] alias to_rgb rgb
|
24
|
+
# Get the RGB representation of the color.
|
25
|
+
# @return [Array<Integer>]
|
26
|
+
|
27
|
+
# @!method hex
|
28
|
+
# @!parse [ruby] alias to_hex hex
|
29
|
+
# Get the hex representation of the color.
|
30
|
+
# @return [String]
|
31
|
+
|
32
|
+
# Compare with other color value.
|
33
|
+
# @param other [Color, Array<Integer>, String]
|
34
|
+
# @return [Boolean]
|
35
|
+
|
36
|
+
def ==(other)
|
37
|
+
case other
|
38
|
+
when Array
|
39
|
+
rgb == other
|
40
|
+
when String
|
41
|
+
hex == other
|
42
|
+
when self.class
|
43
|
+
rgb == other.rgb
|
44
|
+
else
|
45
|
+
false
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Colordom
|
4
|
+
# Image object implemented in Rust that extracts dominant colors.
|
5
|
+
class Image
|
6
|
+
# @!method initialize(path)
|
7
|
+
# A new instance of Image.
|
8
|
+
# @param path [String, Pathname, File]
|
9
|
+
# @return [Image]
|
10
|
+
# @raise [Error] if path is not a valid image
|
11
|
+
|
12
|
+
# @!method histogram(max_colors)
|
13
|
+
# Get dominant colors using histogram quantization.
|
14
|
+
# @param max_colors [Integer]
|
15
|
+
# @return [Array<Color>]
|
16
|
+
|
17
|
+
# @!method mediancut(max_colors)
|
18
|
+
# Get dominant colors using median cut quantization.
|
19
|
+
# @param max_colors [Integer]
|
20
|
+
# @return [Array<Color>]
|
21
|
+
|
22
|
+
# @!method kmeans(max_colors)
|
23
|
+
# Get dominant colors using k-means clustering.
|
24
|
+
# @param max_colors [Integer]
|
25
|
+
# @return [Array<Color>]
|
26
|
+
end
|
27
|
+
end
|
data/lib/colordom.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
RUBY_VERSION =~ /(\d+\.\d+)/
|
5
|
+
require "colordom/#{$1}/colordom"
|
6
|
+
rescue LoadError
|
7
|
+
require 'colordom/colordom'
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'colordom/error'
|
11
|
+
require 'colordom/color'
|
12
|
+
require 'colordom/image'
|
13
|
+
require 'colordom/version'
|
14
|
+
|
15
|
+
# Module that extracts dominant colors from images
|
16
|
+
# using native extension implemented in Rust.
|
17
|
+
module Colordom
|
18
|
+
class << self
|
19
|
+
# Get dominant colors using histogram quantization.
|
20
|
+
# @param path (see Image#initialize)
|
21
|
+
# @param max_colors (see Image#histogram)
|
22
|
+
# @return (see Image#histogram)
|
23
|
+
# @raise (see Image#initialize)
|
24
|
+
|
25
|
+
def histogram(path, max_colors = 5)
|
26
|
+
image = Image.new(path)
|
27
|
+
image.histogram(max_colors)
|
28
|
+
end
|
29
|
+
|
30
|
+
# Get dominant colors using median cut quantization.
|
31
|
+
# @param path (see Image#initialize)
|
32
|
+
# @param max_colors (see Image#mediancut)
|
33
|
+
# @return (see Image#mediancut)
|
34
|
+
# @raise (see Image#initialize)
|
35
|
+
|
36
|
+
def mediancut(path, max_colors = 5)
|
37
|
+
image = Image.new(path)
|
38
|
+
image.mediancut(max_colors)
|
39
|
+
end
|
40
|
+
|
41
|
+
# Get dominant colors using k-means clustering.
|
42
|
+
# @param path (see Image#initialize)
|
43
|
+
# @param max_colors (see Image#kmeans)
|
44
|
+
# @return (see Image#kmeans)
|
45
|
+
# @raise (see Image#initialize)
|
46
|
+
|
47
|
+
def kmeans(path, max_colors = 5)
|
48
|
+
image = Image.new(path)
|
49
|
+
image.kmeans(max_colors)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
metadata
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: colordom
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.8.0
|
5
|
+
platform: x86_64-linux
|
6
|
+
authors:
|
7
|
+
- Jonian Guveli
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2023-09-18 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake-compiler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.2'
|
55
|
+
description: Extract dominant colors from images using native extension implemented
|
56
|
+
in Rust.
|
57
|
+
email:
|
58
|
+
- jonian@hardpixel.eu
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- CODE_OF_CONDUCT.md
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- lib/colordom.rb
|
67
|
+
- lib/colordom/2.6/colordom.so
|
68
|
+
- lib/colordom/2.7/colordom.so
|
69
|
+
- lib/colordom/3.0/colordom.so
|
70
|
+
- lib/colordom/3.1/colordom.so
|
71
|
+
- lib/colordom/3.2/colordom.so
|
72
|
+
- lib/colordom/color.rb
|
73
|
+
- lib/colordom/error.rb
|
74
|
+
- lib/colordom/image.rb
|
75
|
+
- lib/colordom/version.rb
|
76
|
+
homepage: https://github.com/hardpixel/colordom
|
77
|
+
licenses:
|
78
|
+
- MIT
|
79
|
+
metadata: {}
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ">="
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2.6'
|
89
|
+
- - "<"
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 3.3.dev
|
92
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
requirements: []
|
98
|
+
rubygems_version: 3.4.4
|
99
|
+
signing_key:
|
100
|
+
specification_version: 4
|
101
|
+
summary: Extract dominant colors from images
|
102
|
+
test_files: []
|