@@ -36,19 +36,30 @@ local function stop_job(job)
36
36
job .valid = false
37
37
end
38
38
39
+ -- return "1 image" if amount_of_images is 1 else "<amount_of_images> images"
40
+ local function image_count_to_text (amount_of_images )
41
+ return amount_of_images .. " image" .. (amount_of_images == 1 and " " or " s" )
42
+ end
43
+
44
+ -- print the given message to the user and log the given message
45
+ local function print_and_log (message )
46
+ dt .print (message )
47
+ dt .print_log (message )
48
+ end
49
+
39
50
-- add button to 'selected images' module
40
51
dt .gui .libs .image .register_action (
41
52
" create_thumbnails_button" ,
42
53
" create thumbnails" ,
43
54
function (event , images )
44
- dt . print_log (" creating thumbnails for " .. # images .. " images ..." )
55
+ print_and_log (" creating thumbnails for " .. image_count_to_text ( # images ) .. " ..." )
45
56
46
57
-- create a new progress_bar displayed in darktable.gui.libs.backgroundjobs
47
58
job = dt .gui .create_job (" creating thumbnails..." , true , stop_job )
48
59
49
60
for i , image in pairs (images ) do
50
61
-- generate all thumbnails, a max value of 8 means that also a full size preview image is created
51
- -- check if the mipmap cache directories exist only once
62
+ -- check only once if the mipmap cache directories exist
52
63
image :generate_cache (i == 1 , 0 , 8 )
53
64
54
65
-- update progress_bar
@@ -59,16 +70,17 @@ dt.gui.libs.image.register_action(
59
70
60
71
-- stop early if darktable is shutdown or the cancle button of the progress bar is pressed
61
72
if dt .control .ending or not job .valid then
62
- dt . print_log (" creating thumbnails canceled!" )
73
+ print_and_log (" creating thumbnails canceled after processing " .. i .. " / " .. image_count_to_text ( # images ) .. " !" )
63
74
break
64
75
end
65
76
end
66
77
67
- dt .print_log (" create thumbnails done!" )
68
-
69
- -- stop job and remove progress_bar from ui, but only if not alreay canceled
78
+ -- if job was not canceled
70
79
if (job .valid ) then
80
+ -- stop job and remove progress_bar from ui
71
81
job .valid = false
82
+
83
+ print_and_log (" creating thumbnails for " .. image_count_to_text (# images ) .. " done!" )
72
84
end
73
85
end ,
74
86
" create full sized previews of all selected images"
0 commit comments