File size: 977 Bytes
7b615ae
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#encoding=utf8
import os
from PIL import Image
import scripts.config as config

target = config.masks
extension_destination = '.png'

print('Starting processing...')
files = os.listdir(target)
for fileOne in files:
    nameFile, extension = os.path.splitext(fileOne)
    print('Testing: ', fileOne)
    if((extension != extension_destination) and 
       (extension != '.json')):
        if(extension == ''):
            extension = '....'

        print('\nRenaming: ' + str(fileOne))
        origem = os.path.join(target, fileOne)
        
        destino = fileOne.replace(extension, extension_destination)
        if(extension == '....'):
            destino = destino + extension_destination
        destino = os.path.join(target, destino)
    
        im = Image.open(origem).convert('RGB')
        im.save(destino, 'PNG')
        os.remove(origem)
        print('-----------------------------------------')
    
print('\n\nCompleted...')