@@ -143,7 +143,7 @@ local GUI = {
143
143
attach_button = dt .new_widget (" button" ) {
144
144
label = " " ,
145
145
sensitive = false ,
146
- clicked_callback = function () PHOTILS .attach_tags () end
146
+ clicked_callback = function (self ) PHOTILS .attach_tags () end
147
147
},
148
148
confidence_slider = dt .new_widget (" slider" ) {
149
149
step = 1 ,
@@ -226,16 +226,25 @@ function PHOTILS.paginate()
226
226
end
227
227
228
228
function PHOTILS .attach_tags ()
229
- local image = dt .gui .selection ()[1 ]
230
- for tag , _ in pairs (PHOTILS .selected_tags ) do
231
- local dt_tag = dt .tags .create (tag )
232
- dt .tags .attach (dt_tag , image )
229
+ local num_selected = # dt .gui .selection ()
230
+ local job = dt .gui .create_job (_ (" Apply tag to image" ), true )
231
+
232
+ for i = 1 , num_selected , 1 do
233
+ local image = dt .gui .selection ()[i ]
234
+ for tag , _ in pairs (PHOTILS .selected_tags ) do
235
+ local dt_tag = dt .tags .create (tag )
236
+ dt .tags .attach (dt_tag , image )
237
+ end
238
+
239
+ job .percent = i / num_selected
240
+ dt .print (_ (" Tags successfully attached to image" ))
233
241
end
234
242
235
- dt . print ( _ ( " Tags successfully attached to image " ))
243
+ job . valid = false
236
244
end
237
245
238
246
function PHOTILS .get_tags (image , with_export )
247
+
239
248
local tmp_file = df .create_tmp_file ()
240
249
local in_arg = df .sanitize_filename (tostring (image ))
241
250
local out_arg = df .sanitize_filename (tmp_file )
@@ -305,7 +314,8 @@ function PHOTILS.on_tags_clicked()
305
314
dt .control .sleep (2000 )
306
315
end
307
316
308
- if not PHOTILS .get_tags (images [1 ], true ) then
317
+ with_export = dt .preferences .read (MODULE_NAME , " export_image_before_for_tags" , " bool" )
318
+ if not PHOTILS .get_tags (images [1 ], with_export ) then
309
319
local msg = string.format (_ (" %s failed, see terminal output for details" ), MODULE_NAME )
310
320
GUI .warning_label .label = msg
311
321
GUI .stack .active = GUI .error_view
@@ -435,6 +445,15 @@ dt.preferences.register(MODULE_NAME,
435
445
_ (" if enabled, the confidence value for each tag is displayed" ),
436
446
true )
437
447
448
+ dt .preferences .register (MODULE_NAME ,
449
+ " export_image_before_for_tags" ,
450
+ " bool" ,
451
+ _ (" photils: use exported image for tag request" ),
452
+ _ (" If enabled, the image passed to photils for tag suggestion is based on the exported, already edited image. " ..
453
+ " Otherwise, the embedded thumbnail of the RAW file will be used for tag suggestion." ..
454
+ " The embedded thumbnail could speedup the tag suggestion but can fail if the RAW file is not supported." ),
455
+ true )
456
+
438
457
dt .register_event (" photils" , " mouse-over-image-changed" ,
439
458
PHOTILS .image_changed )
440
459
0 commit comments