Created
June 29, 2015 16:29
-
-
Save jmaicher/a83e612b0b5404ad1de4 to your computer and use it in GitHub Desktop.
catpix.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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