Skip to content

Instantly share code, notes, and snippets.

@maehrm
Created January 12, 2013 02:13
Show Gist options
  • Select an option

  • Save maehrm/4515691 to your computer and use it in GitHub Desktop.

Select an option

Save maehrm/4515691 to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
require 'RMagick'
include Magick
arr = []
embedded = ImageList.new('embedded.png')
(0...embedded.rows).each {|y|
(0...embedded.columns).each {|x|
pixel = embedded.pixel_color(x, y)
arr << (((pixel.red & 0x07) << 5) |
((pixel.green & 0x03) << 3) |
(pixel.blue & 0x07))
}
}
puts arr.reject!(&:zero?).pack('C*').force_encoding('utf-8')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment