Multicolor
An opinionated library to ease usage of TinEye's fabulous MulticolorEngine http://services.tineye.com/MulticolorEngine.
Full API documentation available at http://multicolorengine.tineye.com/docs/
Installation
Add this line to your application's Gemfile:
gem 'multicolor'
And then execute:
$ bundle
Or install it yourself as:
$ gem install multicolor
Usage Examples
Instantiating a client
client = Multicolor::REST::Client.new do |client|
client.config.company = "<api-company>"
client.config.username = "<api-username>"
client.config.password = "<password>"
end
Adding or deleting items
data = [
{
url: "http://url-to-image",
filepath: "/path/to/image",
metadata: {
...
}
},
{
url: "http://url-to-other-image",
filepath: "/path/to/another/image",
metadata: {
...
}
},
]
client.add(data) # add the image to the collection
client.delete(["/path/to/image", another_"/path/to/image"] ) # delete images
client.delete("/path/to/image") # pass a single filepath to delete a single image
searching the index
# searching for similar colors
params = {
colors: [
{
color: #rgb or hex
width: 1-100
}...
],
min_score: 0-11
offset: integer
...
}
# Multicolor::REST::SearchBuilder is a convenience method
# that formats params to format required by
# the MulticolorEngine, eg: color[0], color[1]....
= Multicolor::REST::SearchBuilder.new(params).request
response = client.color_search()
response.body # returns API response
Metadata
# extract colors for n images identified by filepath
= {
filepaths: ["/path/to/image", "/path/to/another/image"]
limit: 20
}
client.extract_collection_colors()
# extract metadata for n images
client.(filepaths: ["/path/to/image"])
# count collection colors
= {
count_colors: ["233,233,233","23,33,91"]
filepaths: ["/path/to/image", "/path/to/other/image"]
...
}
client.count_collection_colors()
Info
# counting items in the collection/index
client.count
# List the images present in your API.
client.list
# pinging the API to see if the Piximilar search server is running.
client.ping
Contributing
- Fork it
- Create your feature branch (
git checkout -b my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin my-new-feature) - Create new Pull Request