Skip to content

Commit

Permalink
preserve original import filename in xmp data
Browse files Browse the repository at this point in the history
  • Loading branch information
zisoft authored and TurboGit committed Aug 26, 2024
1 parent b70b25e commit 9cbb4a8
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/common/exif.cc
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,8 @@ const char *dt_xmp_keys[]
"Xmp.acdsee.notes", "Xmp.dc.creator",
"Xmp.dc.publisher", "Xmp.dc.title",
"Xmp.dc.description", "Xmp.dc.rights",
"Xmp.dc.format", "Xmp.xmpMM.DerivedFrom" };
"Xmp.dc.format", "Xmp.xmpMM.DerivedFrom",
"Xmp.xmpMM.PreservedFileName" };

// The number of XmpBag XmpSeq keys that dt uses
static const guint dt_xmp_keys_n = G_N_ELEMENTS(dt_xmp_keys);
Expand Down
3 changes: 2 additions & 1 deletion src/common/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ static const struct
{"Xmp.dc.rights", N_("rights"), DT_METADATA_TYPE_USER, 4},
{"Xmp.acdsee.notes", N_("notes"), DT_METADATA_TYPE_USER, 5},
{"Xmp.darktable.version_name", N_("version name"), DT_METADATA_TYPE_OPTIONAL, 6},
{"Xmp.darktable.image_id", N_("image id"), DT_METADATA_TYPE_INTERNAL, 7}
{"Xmp.darktable.image_id", N_("image id"), DT_METADATA_TYPE_INTERNAL, 7},
{"Xmp.xmpMM.PreservedFileName", N_("preserved filename"), DT_METADATA_TYPE_OPTIONAL, 8}
// clang-format on
};

Expand Down
1 change: 1 addition & 0 deletions src/common/metadata.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ typedef enum dt_metadata_t
DT_METADATA_XMP_ACDSEE_NOTES,
DT_METADATA_XMP_VERSION_NAME,
DT_METADATA_XMP_IMAGE_ID,
DT_METADATA_XMP_PRESERVED_FILENAME,
DT_METADATA_NUMBER
}
dt_metadata_t;
Expand Down
7 changes: 7 additions & 0 deletions src/control/jobs/control_jobs.c
Original file line number Diff line number Diff line change
Expand Up @@ -2373,6 +2373,13 @@ static int _control_import_image_copy(const char *filename,
dt_datetime_unix_to_exif(dt_txt, sizeof(dt_txt), &datetime);
char *id = g_strconcat(fn, "-", dt_txt, NULL);
dt_metadata_set(imgid, "Xmp.darktable.image_id", id, FALSE);
gchar *output_basename = g_path_get_basename(output);
if(g_strcmp0(output_basename, fn))
{
// file renamed during import, preserve the original filename
dt_metadata_set(imgid, "Xmp.xmpMM.PreservedFileName", fn, FALSE);
}
g_free(output_basename);
g_free(id);
g_object_unref(info);
g_object_unref(gfile);
Expand Down
13 changes: 12 additions & 1 deletion src/libs/metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
#endif
#include <gdk/gdkkeysyms.h>

DT_MODULE(3)
DT_MODULE(4)

typedef enum dt_metadata_pref_cols_t
{
Expand Down Expand Up @@ -870,6 +870,17 @@ void *legacy_params(dt_lib_module_t *self,
*new_version = 3;
return new_params;
}
else if(old_version == 3)
{
const size_t new_params_size = old_params_size + 1;
char *new_params = calloc(sizeof(char), new_params_size);

memcpy(new_params, old_params, old_params_size);

*new_size = new_params_size;
*new_version = 4;
return new_params;
}
return NULL;
}

Expand Down
2 changes: 1 addition & 1 deletion src/libs/metadata_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ static const char *_labels[] = {

/* xmp */
//FIXME: reserve DT_METADATA_NUMBER places
"","","","","","","","",
"","","","","","","","","",

/* geotagging */
N_("latitude"),
Expand Down

0 comments on commit 9cbb4a8

Please sign in to comment.