-
Notifications
You must be signed in to change notification settings - Fork 648
Expand file tree
/
Copy pathhtml.py
More file actions
75 lines (69 loc) · 1.34 KB
/
Copy pathhtml.py
File metadata and controls
75 lines (69 loc) · 1.34 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import os
import sys
def run(in_folder, out_folder):
seen = set()
for name in os.listdir(out_folder):
if not name.endswith('.png'):
continue
seen.add(name.split('.')[0])
for name in os.listdir(in_folder):
if not name.endswith('.jpg'):
continue
name = name[:-4]
if name not in seen:
continue
for m in [1, 3, 5]:
print '<tr>'
path = '%s.jpg' % name
print '<td><img src="%s"></td>' % os.path.join(in_folder, path)
for n in [50, 100, 200]:
path = '%s.%d.128.4.%d.png' % (name, n, m)
print '<td><img src="%s"></td>' % os.path.join(out_folder, path)
print '</tr>'
def main():
args = sys.argv[1:]
print HEADER
run(args[0], args[1])
print FOOTER
HEADER = '''
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>PrimitivePic</title>
<style>
body {
margin: 0;
padding: 0;
font-family: sans-serif;
}
table {
border-collapse: collapse;
margin: 4px;
}
img {
width: 400px;
display: block;
margin: 4px;
}
td {
padding: 0;
}
</style>
</head>
<body>
<table>
<tr>
<th>original</th>
<th>50 shapes</th>
<th>100 shapes</th>
<th>200 shapes</th>
</tr>
'''
FOOTER = '''
</table>
</body>
</html>
'''
if __name__ == '__main__':
main()