-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocess.py
66 lines (51 loc) · 1.98 KB
/
process.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import os
import sys
from pidng.core import RPICAM2DNG
input_folder = 'input'
image_extensions = ['.raw', '.jpg', '.jpeg']
raw_files = []
def get_file_extension(filename):
return os.path.splitext(filename)[1].lower()
def convert_image(path):
# pass camera reference into the converter.
file = RPICAM2DNG().convert(path)
return file
def init():
global raw_files
try:
print('''
_____________________________________________
| |
| RaspiStill JPEG+RAW to DNG files converter |
|_____________________________________________|
''')
for arg in sys.argv[1:]:
isDir = os.path.isdir(arg)
if (isDir):
for f in os.listdir(arg):
file_path = os.path.join(arg, f)
if os.path.isfile(file_path) and (get_file_extension(f) in image_extensions):
raw_files.append(file_path)
elif (not isDir) and (get_file_extension(arg) in image_extensions):
raw_files.append(arg)
if len(raw_files):
for raw_file in raw_files:
# If the file is an MP4, convert it to SRT format
filepath = raw_file
print(f'-> CONVERTING FILE {raw_file}')
final_file = convert_image(filepath)
print(f'--> CREATED FILE {final_file}')
else:
print('''
Extract the raw information from RaspiStill JPEG+RAW images and convert it to DNGs files.
How to use:
- Drag and drop image files or the folders that contain them into the .exe
- Valid extensions are JPEG, JPG and RAW
- The new DNG files will be created next to the original ones using the same filename
''')
except Exception as e:
print("An error has ocurred:")
print(e)
input("Press Enter to exit...")
if __name__ == '__main__':
init()