jonbuda / miro Goto Github PK
View Code? Open in Web Editor NEWA Ruby gem to help extract the dominant colors from an image.
License: MIT License
A Ruby gem to help extract the dominant colors from an image.
License: MIT License
I find when image src use base64,it can't work.
how do I add options to deal with base64 images?
Thank you .
hi!
cocaine is deprecated and have been renamed Terrapin:
https://github.com/thoughtbot/cocaine
Upgrading to Terrapin is expected to be as simple as replacing the Cocaine constant with Terrapin.
Cocaine::CommandLine.new("echo", "hello")
should become
Terrapin::CommandLine.new("echo", "hello")
This is not a big issue, but this occurs a noisy log everytime we launch a server
Thank you !
Hi. I'm getting this error. Can you please help me?
sh: /usr/bin/convert: is a directory
Cocaine::ExitStatusError: Command '/usr/bin/convert ''/var/folders/ln/_nb7zgd52zsby0vqqs3h316r0000gn/T/source20140113-5346-14ic4j6.jpg'[0]' -resize '150x150' -colors '8' -colorspace 'RGB' -quantize 'RGB' '/var/folders/ln/_nb7zgd52zsby0vqqs3h316r0000gn/T/downsampled20140113-5346-dnq1fq.png'' returned 126. Expected 0
Here is the command output:
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247/gems/cocaine-0.5.3/lib/cocaine/command_line.rb:91:in `run'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247/gems/miro-0.2.3/lib/miro/dominant_colors.rb:49:in `downsample_colors_and_convert_to_png!'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247/gems/miro-0.2.3/lib/miro/dominant_colors.rb:34:in `extract_colors_from_image'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247/gems/miro-0.2.3/lib/miro/dominant_colors.rb:29:in `sorted_pixels'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247/gems/miro-0.2.3/lib/miro/dominant_colors.rb:11:in `to_hex'
from (irb):8
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.1/lib/rails/commands/console.rb:90:in `start'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.1/lib/rails/commands/console.rb:9:in `start'
from /Users/mariocarvalho/.rvm/gems/ruby-2.0.0-p247@global/gems/railties-4.0.1/lib/rails/commands.rb:62:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
I had to downgrade my ImageMagick version to the ImageMagick 6.7.7-10 2015-01-19 Q16
. Since I downgraded it, the RGB extraction stopped working for me. I don't know if it is a bug. Are you able to help me with that?
The Miro object looks like this:
#<Miro::DominantColors:0x007f84fe872ca8 @image_type=nil, @src_image_path="public/images/swatches/313/original/swatch-313-ha02-25-001.tif">
and I am calling to_rgb
on it.
Thank you in advance. I am using MacOS Yosemite.
This is the result:
convert: profile 'icc': 'RGB ': RGB color space not permitted on grayscale PNG `/var/folders/8x/5cpkltc94j79q9vyt76pw9pw0000gn/T/downsampled20150121-1483-8xgvxs.png' @ error/png.c/MagickPNGErrorHandler/1728.
Cocaine::ExitStatusError: Command '/usr/local/bin/convert ''.../images/swatches/313/original/swatch-313-ha02-25-001.tif'[0]' -resize '150x150' -colors '4' -colorspace 'RGB' -quantize 'RGB' '/var/folders/8x/5cpkltc94j79q9vyt76pw9pw0000gn/T/downsampled20150121-1483-8xgvxs.png'' returned 1. Expected 0
Here is the command output:
from /.rvm/gems/ruby-2.0.0-p195@global/gems/cocaine-0.5.4/lib/cocaine/command_line.rb:96:in `run'
UPDATE:
I implemented a hotfix here:
https://github.com/fbrix/miro/commit/6b4fc08990d60c937fffd542751bf10a283babaf
I think there is a problem with the PNG conversion with the older ImageMagick version.
Is here way to limit colours to specific amount during extraction? for example 16/64/256 instead of full hex range
It looks like there hasn't been a new official release of this gem since 2016; is the preferred method to reference github directly, or will a new release be cut soon? Came here in reference to the cocaine/terrapin deprecation.
Thanks in advance!
I have a loop that runs through a list of image-urls and opens the url with
Miro::DominantColors.new('http://www.example.com/image.jpg')
for some images it returns:
convert: Empty input file `/tmp/source20120709-6914-7hzuos.jpg' @ error/jpeg.c/EmitMessage/236.
convert: missing an image filename `/tmp/downsampled20120709-6914-1ldgk69.png' @ error/convert.c/ConvertImageCommand/3011.
/home/wolle/.rvm/gems/ruby-1.9.3-p194/gems/cocaine-0.2.1/lib/cocaine/command_line.rb:39:in `run': Command '/usr/bin/convert '/tmp/source20120709-6914-7hzuos.jpg' -resize '150x150' -colors '8' '/tmp/downsampled20120709-6914-1ldgk69.png'' returned 1. Expected 0 (Cocaine::ExitStatusError)
from /home/wolle/.rvm/gems/ruby-1.9.3-p194/gems/miro-0.2.1/lib/miro/dominant_colors.rb:46:in `downsample_colors_and_convert_to_png!'
from /home/wolle/.rvm/gems/ruby-1.9.3-p194/gems/miro-0.2.1/lib/miro/dominant_colors.rb:33:in `extract_colors_from_image'
from /home/wolle/.rvm/gems/ruby-1.9.3-p194/gems/miro-0.2.1/lib/miro/dominant_colors.rb:28:in `sorted_pixels'
from /home/wolle/.rvm/gems/ruby-1.9.m3-p194/gems/miro-0.2.1/lib/miro/dominant_colors.rb:10:in `to_hex'
from color.rb:23:in `get_main_color'
from color.rb:55:in `block in start'
from color.rb:50:in `each'
from color.rb:50:in `start'
from color.rb:19:in `initialize'
from color.rb:66:in `new'
from color.rb:66:in `<main>
i tripple checked. all the image-urls are correct. what else could be the problem?
When using convert on animated gifs, it dumps them per frame, like tempfile-1.png, tempfile-2.png, etc, so miro can't get a color palette.
Suggesting skord/miro@85001e0 as a fix. Modifies the convert argument to use the first frame. If there's only one frame, as with most static images, it doesn't matter.
Hi,
How can I set default color palette for scan images?
Or similar functionality https://github.com/humanmade/Colors-Of-Image
Thx.
Hi!
First of all I really like the job that you made with this gem, but while I was reading the code I found that you do a lot unnecesary operations on the image processing like:
resize -> write -> load resized image -> group and arrange pixels -> delete temporaly files
I think a best approach it will be use directly the histogram from rmagick o even from mini_magick instead of use chunky_png which is slower than rmagick and at the end you will have something like this:
resize on memory -> fetch histogram
btw I am not just talking Im working on the solution too
Cheers
For example, if most of the image is white/gray/black, but there's a small or huge pop of pink or blue, can I grab just that pink or blue?
I have been dealing with upcoming Amazon S3 changes for disabling SSLv3 support.
We use miro to test remote images.
What HTTP client is used here? excon?
https://github.com/jonbuda/miro/blob/master/lib/miro/dominant_colors.rb#L95
Will this open call use TLS?
Is there any way to figure out if an image has a transparent background with this gem?
I need only get image and each pixel 0..255 (rgb to char)
After updating to 0.4.0 I get 'Wrong number of arguments (7 for 6)' on
path = "/var/www/app/public/images/avatars/my_image.jgp"
colors = Miro::DominantColors(path)
colors.to_hex # here I get the error
I'm running this from my Rails app using Ruby 2.2.5
What can cause this type or error?
Was detecting the url http://pagead2.googlesyndication.com/simgad/9187813815045956841 as a local file and giving this error
Errno::ENOENT: No such file or directory @ rb_sysopen - /var/folders/ss/tbk3ffkj0snff_tgm5wp0wj00000gn/T/source20160428-33492-5fpoq7./simgad/9187813815045956841 from /Users/RoccoBasso/.rvm/rubies/ruby-2.2.4/lib/ruby/2.2.0/tempfile.rb:136:in
initialize'` so I had to wrap in a begin/rescue block
I tried with an image all blue (#0099cc) and the Miro found the blue color as dominant but with another hex code the #00509c.
There some setup to calibrate the color detection?
Some companies will only use gems with a certain license.
The canonical and easy way to check is via the gemspec
via e.g.
spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']
Bundler now generates gems with a default 'MIT' license. There is even a License Finder
to help companies ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec.
Including a license in your gemspec is a good practice, in any case.
If you need help choosing a license, github has created a license picker tool
How did I find you?
I'm using a script to collect stats on gems, originally looking for download data, but decided to collect licenses too,
and make issues for gemspecs not specifying a license as a public service :)
So far it's going pretty well.
I've written a blog post about it
Hey man, your gem is great, I'm using it and I love, however it can be better. I'm extracting colors from an image in my site, but the colors returned differ a little bit from those of the image. I found out that it's due to the colorspace, I had to change it to sRGB, the problem es that your gem uses the same option (quantize) for quantize and colorpace. I suggest you adding an extra option for the colorspace. I had to do the following in my code:
def image_magick_params
if Miro.histogram?
"':in[0]' -resize :resolution -colors :colors -colorspace \"sRGB\" -quantize :quantize -alpha remove -format %c histogram:info:"
else
"':in[0]' -resize :resolution -colors :colors -colorspace \"sRGB\" -quantize :quantize :out"
end
end
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.