Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/common/darktable.c
Original file line number Diff line number Diff line change
Expand Up @@ -1389,15 +1389,16 @@ int dt_init(int argc,
g_free(theversion);
}

if(myoptions)
if(myoptions && darktable.unmuted)
{
dt_print(DT_DEBUG_ALWAYS, "[dt starting]");
dt_print_nts(DT_DEBUG_ALWAYS, "[dt starting] as :");
int k = 0;
while(myoptions[k])
dt_print_nts(DT_DEBUG_ALWAYS, " %s", myoptions[k++]);
dt_print_nts(DT_DEBUG_ALWAYS, "\n");
g_strfreev(myoptions);
}
if(myoptions)
g_strfreev(myoptions);

if(darktable.dump_pfm_module
|| darktable.dump_pfm_pipe
Expand Down
5 changes: 4 additions & 1 deletion src/common/gimp.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@
gboolean dt_export_gimp_file(const dt_imgid_t imgid)
{
const gboolean thumb = dt_check_gimpmode("thumb");
char *tmp_directory = g_dir_make_tmp("darktable_XXXXXX", NULL);
/* We always export to a temporary location provided by the OS but want that
to be tested via the filename pattern so let's some kind of magic here.
*/
char *tmp_directory = g_dir_make_tmp("XDT2GIMP_XXXXXX", NULL);
char *path = g_build_filename(tmp_directory, thumb ? "thumb" : "image", NULL);
g_free(tmp_directory);

Expand Down
59 changes: 42 additions & 17 deletions src/imageio/storage/disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,19 @@ int store(dt_imageio_module_storage_t *self,
char input_dir[PATH_MAX] = { 0 };
char pattern[DT_MAX_PATH_FOR_PARAMS];
g_strlcpy(pattern, d->filename, sizeof(pattern));

/* If we are in gimp plugin mode we can either export on purpose by using the
export interface or we do the final export - when quitting the plugin -
to the file that is later presented to GIMP as defined in the --gimp API
We have to test for this as we don't want the variable expand stepping in.
*/
const gboolean variable_expand = dt_gimpmode()
? (g_strrstr(pattern, "XDT2GIMP") == NULL)
: TRUE;
dt_print(DT_DEBUG_IMAGEIO, "disk store :%s: `%s'",
variable_expand ? "expand variables" : "FINAL GIMP EXPORT",
pattern);

dt_image_full_path(imgid, input_dir, sizeof(input_dir), NULL);
// set variable values to expand them afterwards in darktable variables
dt_variables_set_max_width_height(d->vp, fdata->max_width, fdata->max_height);
Expand All @@ -350,37 +363,49 @@ int store(dt_imageio_module_storage_t *self,
{
try_again:
// avoid braindead export which is bound to overwrite at random:
if(total > 1 && !g_strrstr(pattern, "$"))
if(variable_expand && total > 1 && !g_strrstr(pattern, "$"))
{
snprintf(pattern + strlen(pattern),
sizeof(pattern) - strlen(pattern), "_$(SEQUENCE)");
}

gchar *fixed_path = dt_util_fix_path(pattern);
g_strlcpy(pattern, fixed_path, sizeof(pattern));
g_free(fixed_path);
if(variable_expand)
{
gchar *fixed_path = dt_util_fix_path(pattern);
g_strlcpy(pattern, fixed_path, sizeof(pattern));
g_free(fixed_path);
}

d->vp->filename = input_dir;
d->vp->jobcode = "export";
d->vp->imgid = imgid;
d->vp->sequence = num;

gchar *result_filename = dt_variables_expand(d->vp, pattern, TRUE);
g_strlcpy(filename, result_filename, sizeof(filename));
g_free(result_filename);

// if filenamepattern is a directory just add ${FILE_NAME} as
// default.. this can happen if the filename component of the
// pattern is an empty variable
const char last_char = *(filename + strlen(filename) - 1);
if(last_char == '/' || last_char == '\\')
if(variable_expand)
{
// add to the end of the original pattern without caring about a
// potentially added "_$(SEQUENCE)"
if(snprintf(pattern, sizeof(pattern), "%s"
gchar *result_filename = dt_variables_expand(d->vp, pattern, TRUE);
g_strlcpy(filename, result_filename, sizeof(filename));
g_free(result_filename);

// if filenamepattern is a directory just add ${FILE_NAME} as
// default.. this can happen if the filename component of the
// pattern is an empty variable
const char last_char = *(filename + strlen(filename) - 1);
if(last_char == '/' || last_char == '\\')
{
// add to the end of the original pattern without caring about a
// potentially added "_$(SEQUENCE)"
if(snprintf(pattern, sizeof(pattern), "%s"
G_DIR_SEPARATOR_S "$(FILE_NAME)", d->filename) < sizeof(pattern))
goto try_again;
goto try_again;
}
}
else
{
// we don't expand via variables but take what we got as pattern
g_strlcpy(filename, pattern, sizeof(filename));
}


// get the directory path of the output file
char *output_dir = g_path_get_dirname(filename);
Expand Down
Loading