File size: 1,397 Bytes
5bbe62a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import os
import sys
import subprocess
from concurrent.futures import ThreadPoolExecutor

output_dir = 'target_imgs_v73'

def process_skin(skin_id):
    input_path = f'skins/{skin_id}.png'
    output_path = f'{output_dir}/{skin_id}.png'
    if not os.path.exists(output_path):
        print(f"Starting process for skin: {skin_id}...")
        # Run build_target_img.py as a separate subprocess using sys.executable
        result = subprocess.run(
            [sys.executable, 'build_target_img.py', input_path, output_path],
            capture_output=True,
            text=True
        )
        if result.returncode == 0:
            print(f"Successfully processed: {skin_id}")
        else:
            print(f"Error processing skin {skin_id}:")
            print(result.stderr or result.stdout)

def main():
    os.makedirs(output_dir, exist_ok=True)
    iset = set()
    for i in os.listdir('skins'):
        if i.endswith('.png') and not i.startswith('.'):
            iset.add(i.split('.')[0])
            
    # Process skins in parallel using a pool of subprocesses
    # Using 4 workers for fast parallel rendering on Mac
    max_workers = 4 
    print(f"Processing {len(iset)} skins using {max_workers} parallel workers...")
    with ThreadPoolExecutor(max_workers=max_workers) as executor:
        executor.map(process_skin, sorted(list(iset)))

if __name__ == '__main__':
    main()