-
Notifications
You must be signed in to change notification settings - Fork 18
/
gather.py
executable file
·45 lines (30 loc) · 1.18 KB
/
gather.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/usr/bin/env python
import os
import os.path
import shutil
import subprocess
in_path = "/Users/eric/Library/Application Support/Google/Chrome/Default/File System/030/p/"
out_path = "/Users/WebstormProjects/gl-water2d/lol2_frames/"
in_file_num = 0
out_frame_num = 0
# create output directory if necessary.
if not os.path.exists(out_path):
os.makedirs(out_path)
while True:
if in_file_num % 100 == 0:
print "Copied ", in_file_num, "frames"
in_file_num_str = str(in_file_num).rjust(8,'0')
in_sub_dir = str(int(in_file_num / 100) ).rjust(2,'0') + "/"
in_full_path = os.path.join(in_path, in_sub_dir,in_file_num_str)
in_full_path_tga = in_full_path + ".tga"
if not os.path.isfile(in_full_path):
break
os.rename(in_full_path, in_full_path_tga)
out_file = "frame" + str(out_frame_num).rjust(8,'0') + ".png"
out_full_path = os.path.join(out_path, out_file)
# if using graphicsmagick.
subprocess.call([ "gm", "convert", in_full_path_tga, out_full_path ] )
# if using imagemagick
# subprocess.call([ "convert", in_full_path_tga, out_full_path ] )
in_file_num = in_file_num + 1
out_frame_num = out_frame_num + 1