ruby challenge 7

smarty

This challenge gives you a picture with the a weird horizontal grey streak running through it. Obviously something hidden in the image data. I originally found the direction for this solution by converting the image to a bitmap and opening it in a hex editor. However it is much easier to extract the message with ImageMagick, or in this case RMagic the ruby bindings for ImageMagick. This ones a little tricky it is actually a puzzle in a puzzle. I had a solution last night that was kinda long and I knew I could do better, so this morning I completely rewrote it at less then half it original length.

#!/usr/bin/ruby
require 'RMagick'
include Magick 
rPix = ImageList.new("./oxygen.png").crop!(0, 45, 609, 7).sample!(87,7)
pixDat = rPix.export_pixels_to_str(0, 0, 87, 1, "R")
puts pixDat.scan(/[0-9]+/).collect{|ascii|ascii.to_i.chr}.join
 

I cheated a little, I used Gimp to check geometry and get the numbers used in the script. I could have scripted the whole thing but that would have added a couple more lines.

Next: challenge 8; working hard?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s