<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,40 +1,54 @@
 require &quot;rubygems&quot;
-require &quot;RMagick&quot;
+require &quot;rmagick&quot;
+require 'pp'
 
-if !ARGV[0]
-    puts &quot;Usage: polaroid.rb path-to-image&quot;
-    exit
+def exit_with_help_message
+  puts &quot;Usage: #{$0} /path/to/image.png&quot;
+  exit
 end
 
-image = Magick::Image.read(ARGV[0]).first
-
-image.border!(18, 18, &quot;#f0f0ff&quot;)
-
-# Bend the image
-image.background_color = &quot;none&quot;
-
-amplitude = image.columns * 0.01        # vary according to taste
-wavelength = image.rows  * 2
-
-image.rotate!(90)
-image = image.wave(amplitude, wavelength)
-image.rotate!(-90)
-
-# Make the shadow
-shadow = image.flop
-shadow = shadow.colorize(1, 1, 1, &quot;gray75&quot;)     # shadow color can vary to taste
-shadow.background_color = &quot;none&quot;       # was &quot;none&quot;
-shadow.border!(10, 10, &quot;white&quot;)
-shadow = shadow.blur_image(0, 3)        # shadow blurriness can vary according to taste
-
-# Composite image over shadow. The y-axis adjustment can vary according to taste.
-image = shadow.composite(image, -amplitude/2, 5, Magick::OverCompositeOp)
+module Magick
+  class Image
+    def polaroidify
+      image = self
+      image.border!(18, 18, &quot;#f0f0ff&quot;)
+      image.background_color = &quot;none&quot;
+
+      # Warpy
+      amplitude = image.columns * 0.01
+      wavelength = image.rows  * 2
+      image.rotate!(90)
+      image = image.wave(amplitude, wavelength)
+      image.rotate!(-90)
+      
+      # Shadowy
+      shadow = image.flop
+      shadow = shadow.colorize(1, 1, 1, &quot;gray75&quot;)
+      shadow.background_color = &quot;none&quot;
+      shadow.border!(10, 10, &quot;white&quot;)
+      shadow = shadow.blur_image(0, 3)
+      
+      # Mergy
+      image = shadow.composite(image, -amplitude/2, 5, Magick::OverCompositeOp)
+      image.background_color = &quot;white&quot;
+      image.rotate!(-5)
+      image.trim!
+      
+      image
+    end    
+  end
+end
 
-image.rotate!(-5)                       # vary according to taste
-image.trim!
+def write_to_file!(image)
+  out = @image_path.sub(/\./, &quot;-print.&quot;)
+  puts &quot;Writing #{out}&quot;
+  image.write(out)
+end
 
-# Add -print to image basename, write to file.
-out = ARGV[0].sub(/\./, &quot;-print.&quot;)
-puts &quot;Writing #{out}&quot;
-image.write(out)
+if $0 == __FILE__
+  exit_with_help_message unless ARGV[0] &amp;&amp; File.exists?(ARGV[0])
 
+  @image_path = ARGV[0]
+  image = Magick::Image.read(@image_path).first.polaroidify
+  write_to_file!(image)
+end
\ No newline at end of file</diff>
      <filename>hacks/rb/polaroid.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>ae67b476546b21604d3cdaead620e602b20bfcae</id>
    </parent>
  </parents>
  <author>
    <name>Marc Chung</name>
    <email>mchung@stargate.local</email>
  </author>
  <url>http://github.com/mchung/mchung-code/commit/110fa07eb943c1a42b1926cdff298e2c1f9141bc</url>
  <id>110fa07eb943c1a42b1926cdff298e2c1f9141bc</id>
  <committed-date>2008-07-06T11:48:34-07:00</committed-date>
  <authored-date>2008-07-06T11:48:34-07:00</authored-date>
  <message>Idiomatic ruby style</message>
  <tree>d6b7d558f97a3f565c1c5739cfe7032fbee15493</tree>
  <committer>
    <name>Marc Chung</name>
    <email>mchung@stargate.local</email>
  </committer>
</commit>
