19 parser = argparse.ArgumentParser(description=
"Split a sequence of pictures to Crossfire faces and animations, adequately named for an aura. "
20 "Generate the .face file with the corresponding animations.")
21 parser.add_argument(
'files', nargs=
'+')
22 parser.add_argument(
'--faceset', default=
"base", type=str, help=
'faceset to generate the face for, default "base"')
23 parser.add_argument(
'--name', required=
True, type=str, help=
'name of the faces and animations to generate')
24 parser.add_argument(
'--size', required=
True, type=int, help=
'number of faces to make for each size')
25 parser.add_argument(
'--magicmap', type=str, help=
'color to assign the face on the magicmap, default none so no magic '
27 parser.add_argument(
'--license', type=str, help=
'License file to use for these faces')
29 args = parser.parse_args()
31 print(
"Making split animation and faces for '{0}'.".format(args.name))
33 frames = len(args.files)
36 with open(
'{0}.face'.format(args.name),
'w')
as anim_file:
37 for x
in range(0, args.size):
38 for y
in range(0, args.size):
39 anim_file.write(
'animation {0}_{1}_{2}\n'.format(args.name, x, y))
40 for f
in range(0, frames):
41 face_name =
'{0}.{1}{2}{3}\n'.format(args.name, x, y, f)
42 anim_file.write(face_name)
43 subprocess.call([
'convert',
'-extract',
'32x32+{0}+{1}'.format(x * 32, y * 32), args.files[f],
'{0}.{1}.{2}{3}{4}.png'.format(args.name, args.faceset, x, y, f)])
45 magicmap +=
'face {0}magicmap {1}\nend\n'.format(face_name, args.magicmap)
46 anim_file.write(
'mina\n')
47 anim_file.write(magicmap)
50 shutil.copyfile(args.license,
"{0}.{1}.LICENSE".format(args.name, args.faceset))