41
41
* require this script from your main lua file
42
42
* select an image or images for editing with GIMP
43
43
* in the export dialog select "Edit with GIMP" and select the format and bit depth for the
44
- exported image
44
+ exported image. Check the "run_detached" button to run GIMP in detached mode. Images
45
+ will not be returned to darktable in this mode, but additional images can be sent to
46
+ GIMP without stopping it.
45
47
* Press "export"
46
48
* Edit the image with GIMP then save the changes with File->Overwrite....
47
49
* Exit GIMP
103
105
104
106
local function gimp_edit (storage , image_table , extra_data ) -- finalize
105
107
108
+ local run_detached = dt .preferences .read (" gimp" , " run_detached" , " bool" )
109
+
106
110
local gimp_executable = df .check_if_bin_exists (" gimp" )
107
111
108
112
if not gimp_executable then
@@ -111,7 +115,11 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
111
115
end
112
116
113
117
if dt .configuration .running_os == " macos" then
114
- gimp_executable = " open -W -a " .. gimp_executable
118
+ if run_detached then
119
+ gimp_executable = " open -a " .. gimp_executable
120
+ else
121
+ gimp_executable = " open -W -a " .. gimp_executable
122
+ end
115
123
end
116
124
117
125
-- list of exported images
@@ -130,54 +138,67 @@ local function gimp_edit(storage, image_table, extra_data) --finalize
130
138
local gimpStartCommand
131
139
gimpStartCommand = gimp_executable .. " " .. img_list
132
140
141
+ if run_detached then
142
+ if dt .configuration .running_os == " windows" then
143
+ gimpStartCommand = " start /b \"\" " .. gimpStartCommand
144
+ else
145
+ gimpStartCommand = gimpStartCommand .. " &"
146
+ end
147
+ end
148
+
133
149
dt .print_log (gimpStartCommand )
134
150
135
151
dtsys .external_command (gimpStartCommand )
136
152
137
- -- for each of the image, exported image pairs
138
- -- move the exported image into the directory with the original
139
- -- then import the image into the database which will group it with the original
140
- -- and then copy over any tags other than darktable tags
153
+ if not run_detached then
154
+
155
+ -- for each of the image, exported image pairs
156
+ -- move the exported image into the directory with the original
157
+ -- then import the image into the database which will group it with the original
158
+ -- and then copy over any tags other than darktable tags
141
159
142
- for image ,exported_image in pairs (image_table ) do
160
+ for image ,exported_image in pairs (image_table ) do
143
161
144
- local myimage_name = image .path .. " /" .. df .get_filename (exported_image )
162
+ local myimage_name = image .path .. " /" .. df .get_filename (exported_image )
145
163
146
- while df .check_if_file_exists (myimage_name ) do
147
- myimage_name = df .filename_increment (myimage_name )
148
- -- limit to 99 more exports of the original export
149
- if string.match (df .get_basename (myimage_name ), " _(d-)$" ) == " 99" then
150
- break
164
+ while df .check_if_file_exists (myimage_name ) do
165
+ myimage_name = df .filename_increment (myimage_name )
166
+ -- limit to 99 more exports of the original export
167
+ if string.match (df .get_basename (myimage_name ), " _(d-)$" ) == " 99" then
168
+ break
169
+ end
151
170
end
152
- end
153
171
154
- dt .print_log (" moving " .. exported_image .. " to " .. myimage_name )
155
- local result = df .file_move (exported_image , myimage_name )
172
+ dt .print_log (" moving " .. exported_image .. " to " .. myimage_name )
173
+ local result = df .file_move (exported_image , myimage_name )
156
174
157
- if result then
158
- dt .print_log (" importing file" )
159
- local myimage = dt .database .import (myimage_name )
175
+ if result then
176
+ dt .print_log (" importing file" )
177
+ local myimage = dt .database .import (myimage_name )
160
178
161
- group_if_not_member (image , myimage )
179
+ group_if_not_member (image , myimage )
162
180
163
- for _ ,tag in pairs (dt .tags .get_tags (image )) do
164
- if not (string.sub (tag .name ,1 ,9 ) == " darktable" ) then
165
- dt .print_log (" attaching tag" )
166
- dt .tags .attach (tag ,myimage )
181
+ for _ ,tag in pairs (dt .tags .get_tags (image )) do
182
+ if not (string.sub (tag .name ,1 ,9 ) == " darktable" ) then
183
+ dt .print_log (" attaching tag" )
184
+ dt .tags .attach (tag ,myimage )
185
+ end
167
186
end
168
187
end
169
188
end
170
189
end
171
-
172
190
end
173
191
174
192
-- Register
175
193
176
- local executables = {" gimp" }
177
-
178
- if dt .configuration .running_os ~= " linux" then
179
- gimp_widget = df .executable_path_widget (executables )
180
- end
194
+ gimp_widget = dt .new_widget (" check_button" ){
195
+ label = _ (" run detached" ),
196
+ tooltip = _ (" don't import resulting image back into darktable" ),
197
+ value = dt .preferences .read (" gimp" , " run_detached" , " bool" ),
198
+ clicked_callback = function (this )
199
+ dt .preferences .write (" gimp" , " run_detached" , " bool" , this .value )
200
+ end
201
+ }
181
202
182
203
dt .register_storage (" module_gimp" , _ (" Edit with GIMP" ), show_status , gimp_edit , nil , nil , gimp_widget )
183
204
0 commit comments