File tree 1 file changed +17
-0
lines changed
src/dataset_image_annotator
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 3
3
from pathlib import Path
4
4
from typing import Sequence
5
5
6
+ import rawpy
6
7
from PySide6 .QtCore import QFile , QIODevice
7
8
from PySide6 .QtUiTools import QUiLoader
8
9
from PySide6 .QtWidgets import QApplication
@@ -27,10 +28,23 @@ def list_dir_images(path: Path) -> Sequence[Path]:
27
28
return files
28
29
29
30
31
+ def get_raw_thumbnail (path : Path ):
32
+ with rawpy .imread (str (path )) as raw :
33
+ try :
34
+ thumb = raw .extract_thumb ()
35
+ except rawpy .LibRawNoThumbnailError :
36
+ print ('no thumbnail found' )
37
+ except rawpy .LibRawUnsupportedThumbnailError :
38
+ print ('unsupported thumbnail' )
39
+ else :
40
+ return thumb
41
+
42
+
30
43
def main ():
31
44
args = get_parsed_args ()
32
45
data_root_path = Path (args .data_root )
33
46
image_file_paths = list_dir_images (data_root_path )
47
+ thumb = get_raw_thumbnail (image_file_paths [0 ])
34
48
35
49
app = QApplication (sys .argv )
36
50
@@ -51,6 +65,9 @@ def main():
51
65
52
66
window .show ()
53
67
68
+ with rawpy .imread (image_file_paths [0 ]) as f :
69
+ f .extract_thumb ()
70
+
54
71
sys .exit (app .exec ())
55
72
56
73
You can’t perform that action at this time.
0 commit comments