Skip to content

Instantly share code, notes, and snippets.

@jmaicher
Created June 29, 2015 16:29
Show Gist options
  • Save jmaicher/a83e612b0b5404ad1de4 to your computer and use it in GitHub Desktop.
Save jmaicher/a83e612b0b5404ad1de4 to your computer and use it in GitHub Desktop.
catpix.rb
require "tco"
require "rmagick"
img = Magick::Image::read(ARGV[0]).first
img.each_pixel do |pixel, col, row|
c = [pixel.red, pixel.green, pixel.blue].map { |v| 256 * (v / 65535.0) }
pixel.opacity == 65535 ? print(" ") : print(" ".bg c)
puts if col >= img.columns - 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment