Skip to content

Instantly share code, notes, and snippets.

@johnbintz
Created July 23, 2013 02:36
Show Gist options
  • Save johnbintz/6059444 to your computer and use it in GitHub Desktop.
Save johnbintz/6059444 to your computer and use it in GitHub Desktop.
Process a directory of PNG card files from nanDECK for The Game Crafter
require 'quick_magick'
class CardsBuilder < Thor
no_tasks do
def bordersize(image, color = image.get_pixel(0, 0))
image.gravity = 'center'
image.background = "rgb(#{color.join(',')})"
image.extent "825x1125"
end
end
desc "pngout DIR", "Process PNG files from nanDECK output for The Game Crafter"
def pngout(dir)
Dir["#{dir}/*.png"].sort.each do |file|
image = QuickMagick::Image.read(file).last
bordersize(image)
image.save!
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment