require "eet"
require "imlib2"

Eet::File.open(ARGV.shift) do |ef|
	ef.keys("images/*").sort.each do |key|
		data, w, h, has_alpha = ef.read_image(key)

		im = Imlib2::Image.create_using_copied_data(w, h, data)
		im.format = "png"
		im["quality"] = 99
		im["compression"] = 9
		im.has_alpha = has_alpha

		file = key.gsub(/\//, "_")
		im.save("#{file}.png")
	end
end
