[gimp] plug-ins: don't create a temp dir when using darktable
- From: Tobias Ellinghaus <et src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] plug-ins: don't create a temp dir when using darktable
- Date: Tue, 19 Apr 2016 01:20:33 +0000 (UTC)
commit f89d8fcaa7cd0e0cc44ab74d806f2ba61a9a7a35
Author: Tobias Ellinghaus <me houz org>
Date: Tue Apr 19 02:19:39 2016 +0100
plug-ins: don't create a temp dir when using darktable
plug-ins/file-darktable/export-on-exit.lua | 12 +++++---
plug-ins/file-darktable/file-darktable.c | 39 +++++++++------------------
2 files changed, 20 insertions(+), 31 deletions(-)
---
diff --git a/plug-ins/file-darktable/export-on-exit.lua b/plug-ins/file-darktable/export-on-exit.lua
index 32385d7..b0ed765 100644
--- a/plug-ins/file-darktable/export-on-exit.lua
+++ b/plug-ins/file-darktable/export-on-exit.lua
@@ -18,13 +18,14 @@
--[[
EXPORT ON EXIT
-exports all (but at most 1) images from the database to tmp_dir/out.exr when darktable exits
+exports all (but at most 1) images from the database to prefs setting "lua/export_on_exit/export_filename"
+when darktable exits
USAGE
* require this file from your main lua config file
* or: use --luacmd "dofile('/path/to/this/file.lua')"
-
+* and make sure to set the export filename
]]
@@ -37,6 +38,8 @@ if dt.configuration.api_version_string < min_api_version then
return
end
+local export_filename = dt.preferences.read("export_on_exit", "export_filename", "string")
+
dt.register_event("exit", function()
-- safegurad against someone using this with their library containing 50k images
if #dt.database > 1 then
@@ -52,9 +55,8 @@ dt.register_event("exit", function()
format.max_height = 0
-- let's have the export in a loop so we could easily support > 1 images
for _, image in ipairs(dt.database) do
- local filename = dt.configuration.tmp_dir.."/out."..format.extension
- dt.print_error("exporting `"..tostring(image).."' to `"..filename.."'")
- format:write_image(image, filename)
+ dt.print_error("exporting `"..tostring(image).."' to `"..export_filename.."'")
+ format:write_image(image, export_filename)
end
end)
diff --git a/plug-ins/file-darktable/file-darktable.c b/plug-ins/file-darktable/file-darktable.c
index 83ab6bb..bfe0a04 100644
--- a/plug-ins/file-darktable/file-darktable.c
+++ b/plug-ins/file-darktable/file-darktable.c
@@ -213,25 +213,25 @@ load_image (const gchar *filename,
GimpRunMode run_mode,
GError **error)
{
- gint32 image_ID = -1;
- GFile *lua_file = gimp_data_directory_file ("file-darktable",
- "export-on-exit.lua",
- NULL);
- gchar *lua_script = g_file_get_path (lua_file);
- gchar *lua_quoted = g_shell_quote (lua_script);
- gchar *tempdir = g_strdup ("/tmp/dt4gimp_XXXXXX");
- gchar *lua_cmd = g_strdup_printf ("dofile(%s)", lua_quoted);
- gchar *filename_in = g_strdup (filename);
- gchar *filename_out = NULL;
+ gint32 image_ID = -1;
+ GFile *lua_file = gimp_data_directory_file ("file-darktable",
+ "export-on-exit.lua",
+ NULL);
+ gchar *lua_script = g_file_get_path (lua_file);
+ gchar *lua_quoted = g_shell_quote (lua_script);
+ gchar *filename_out = gimp_temp_name ("exr");
+ gchar *export_filename = g_strdup_printf ("lua/export_on_exit/export_filename=%s", filename_out);
+ gchar *lua_cmd = g_strdup_printf ("dofile(%s)", lua_quoted);
+ gchar *filename_in = g_strdup (filename);
/* linear sRGB for now as GIMP uses that internally in many places anyway */
gchar *argv[] =
{
"darktable",
"--library", ":memory:",
- "--tmpdir", tempdir,
"--luacmd", lua_cmd,
"--conf", "plugins/lighttable/export/iccprofile=linear_rec709_rgb",
+ "--conf", export_filename,
filename_in,
NULL
};
@@ -239,22 +239,10 @@ load_image (const gchar *filename,
g_object_unref (lua_file);
g_free (lua_script);
- if ( ! g_mkdtemp (tempdir))
- {
- g_free (tempdir);
- g_free (lua_quoted);
- g_free (lua_cmd);
- g_free (filename_in);
- return -1;
- }
-
gimp_progress_init_printf (_("Opening '%s'"),
gimp_filename_to_utf8 (filename));
- /* keep the filename in sync with the .lua file! */
- filename_out = g_build_filename (tempdir, "out.exr", NULL);
-
- if (g_spawn_sync (tempdir,
+ if (g_spawn_sync (NULL,
argv,
NULL,
G_SPAWN_STDOUT_TO_DEV_NULL |
@@ -273,12 +261,11 @@ load_image (const gchar *filename,
}
g_unlink (filename_out);
- g_rmdir (tempdir);
- g_free (tempdir);
g_free (lua_quoted);
g_free (lua_cmd);
g_free (filename_in);
g_free (filename_out);
+ g_free (export_filename);
gimp_progress_update (1.0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]