Code: Select all
convert image-input.png -unique-colors -depth 8 txt:- > color.txt
Code: Select all
image = ImageList.new("image-input.png")
image.quantize(number_colors=256, colorspace=RGBColorspace, dither=RiemersmaDitherMethod, tree_depth=0, measure_error=false)
image2 = Image.new(240,240)
color = Pixel.from_color('#E1E1E1')
(0..image.columns).each do |x|
(0..image.rows).each do |y|
pixel = image.pixel_color(x, y)
if pixel.fcmp(color)
image2.pixel_color(x, y, "#000000")
end
end
end