Created
July 23, 2013 02:36
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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