Skip to content

Instantly share code, notes, and snippets.

@jfreyre
Created September 18, 2014 08:34
Show Gist options
  • Save jfreyre/3f27555c64fdef6d94f6 to your computer and use it in GitHub Desktop.
Save jfreyre/3f27555c64fdef6d94f6 to your computer and use it in GitHub Desktop.
start_lvl = 18
end_lvl = 10
start_lvl.downto(end_lvl).each do |current_lvl|
resize_cmd = "convert lvl_#{current_lvl+1}.gif -resize 50% lvl_#{current_lvl}.gif"
puts resize_cmd
output = `#{resize_cmd}`
tile_cmd = "convert lvl_#{current_lvl}.gif -crop 256x256 -set filename:tile \"%[fx:page.x/256+1]_%[fx:page.y/256+1]\" +repage +adjoin \"map_%[filename:tile].png\""
puts tile_cmd
output = `#{tile_cmd}`
create_dir_cmd = "mkdir lvl_#{current_lvl}"
puts create_dir_cmd
output = `#{create_dir_cmd}`
mv_files_cmd = "mv map*.png lvl_#{current_lvl}/"
puts mv_files_cmd
output = `#{mv_files_cmd}`
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment