Skip to content

Instantly share code, notes, and snippets.

@JohnMorales JohnMorales/Gemfile
Last active Aug 29, 2015

Embed
What would you like to do?
ruby loco hack night project to convert an image to ascii art
require 'rmagick'
require 'paint'
unless File.exists? './o-AMERICAN-FLAG-facebook.jpg'
`curl -O http://i.huffpost.com/gen/1649894/images/o-AMERICAN-FLAG-facebook.jpg`
end
resource = open('./o-AMERICAN-FLAG-facebook.jpg')
image = Magick::ImageList.new
image.from_blob resource.read
image = image.scale(150 / image.columns.to_f)
image = image.scale(image.columns, image.rows / 1.7)
cur_row = 0
image.each_pixel do |pixel, col, row|
color = pixel.to_color(Magick::AllCompliance, false, 8)
if cur_row != row
puts
cur_row = row
end
print Paint[' ', '', color]
end
puts
source "https://rubygems.org"
gem 'pry'
# gem "ascii-image"
gem "rmagick", "=2.13.1"
gem "rainbow", "= 1.1.4"
gem "pry-rescue"
gem "paint"
@JohnMorales

This comment has been minimized.

Copy link
Owner Author

JohnMorales commented Jul 13, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.