Skip to content

Instantly share code, notes, and snippets.

@icyleaf
Last active July 4, 2017 09:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save icyleaf/cbc6e567b3a571ac6796a20aff430f2c to your computer and use it in GitHub Desktop.
Save icyleaf/cbc6e567b3a571ac6796a20aff430f2c to your computer and use it in GitHub Desktop.
image = MiniMagick::Image.open('source.jpg')
image.colorspace 'gray'
pixels = image.get_pixels
0.upto(image.height - 1) do |y|
image.combine_options do |c|
0.upto(image.width - 1) do |x|
color = pixels[y][x][0]
c.draw "fill #{black_color} color #{x},#{y} point" if color < 250
end
end
end
image.write('destination.jpg')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment