solve me

While out and about enjoying the holiday season, I began to think about making an NFA Christmas tree that reached an accept state when given a holiday greeting. Voila! I give you the product of my labor. I made the tree using JFLAP. I then exported images of the tree as each letter in the message was read in. Finally, I wrote the small program below to modify the images and stitch them into an animated GIF.

brew install imagemagick
gem install rmagick
require 'rubygems'
require 'rmagick'
include Magick

dir_contents = Dir.glob("xmas_tree_files/*.gif")

image_list = ImageList.new
image_list.delay = 20 # delay 1/5 of a second between images.

dir_contents.each do |file_name|
  image = Image.read("#{file_name}").first
  cropped_image = image.crop!(40,10,800,490,true)
  image_list << cropped_image
end

#make sure to write the animated gif to a different dir 
#than the one that contains your original images,
#otherwise you'll get weirdly animated gifs when you rerun the program
image_list.write("animated_tree.gif")