![]() |
Ansel 0.0
A darktable fork - bloat + design vision
|
The XMP-sidecar half of what used to be common/exif.cc.
More...
#include <errno.h>#include "common/paths.h"#include <glib.h>#include <glib/gstdio.h>#include <time.h>#include <cmath>#include <cstdlib>#include <cstring>#include <fstream>#include <iostream>#include <sstream>#include <string>#include <exiv2/exiv2.hpp>#include <pugixml.hpp>#include "common/xmp_sidecar.h"#include "metadata/exif.h"#include "metadata/exif_internal.h"#include "caches/image_cache.h"#include "common/conf.h"#include "common/datetime.h"#include "common/deprecations.h"#include "history/history.h"#include "common/utility.h"#include "common/variables.h"#include "database/colorlabel_repository.h"#include "database/database.h"#include "database/history_repository.h"#include "database/image_repository.h"#include "database/metadata_repository.h"#include "develop/blend.h"#include "develop/iop_order.h"#include "develop/masks.h"#include "imageio/imageio_core.h"#include "metadata/metadata.h"#include "metadata/notify.h"#include "metadata/tags.h"#include "system/macros.h"#include "system/mem_alloc.h"
Include dependency graph for xmp_sidecar.cc:Go to the source code of this file.
Data Structures | |
| struct | history_entry_t |
| struct | mask_entry_t |
| struct | _xmp_mask_ctx_t |
| struct | _xmp_history_ctx_t |
| struct | _xmp_metadata_ctx_t |
Macros | |
| #define | __STDC_FORMAT_MACROS |
| #define | DT_XMP_EXIF_VERSION 5 |
| #define | ERROR_CODE(a) (a) |
Variables | |
| const char * | dt_xmp_keys [] |
| static const guint | dt_xmp_keys_n = G_N_ELEMENTS(dt_xmp_keys) |
The XMP-sidecar half of what used to be common/exif.cc.
Cut out of a 4775-line translation unit that was doing two unrelated jobs. This one serialises the development – history stack, mask shapes, module order – into and out of the XMP document; the other, the photograph's own tags, is metadata/exif.cc. See common/xmp_sidecar.h, including why this is not in src/metadata.
Definition in file xmp_sidecar.cc.
| #define __STDC_FORMAT_MACROS |
Definition at line 73 of file xmp_sidecar.cc.
| #define DT_XMP_EXIF_VERSION 5 |
Definition at line 135 of file xmp_sidecar.cc.
| #define ERROR_CODE | ( | a | ) | (a) |
Definition at line 2210 of file xmp_sidecar.cc.
| GTimeSpan _convert_unix_to_gtimespan | ( | const time_t | unix | ) |
Definition at line 1781 of file xmp_sidecar.cc.
References dt_datetime_gdatetime_to_gtimespan(), and L.
Referenced by read_xmp_timestamps().
Definition at line 142 of file xmp_sidecar.cc.
References dt_exif_get_exiv2_taglist(), IS_NULL_PTR, L, and t.
Referenced by dt_exif_xmp_attach_export().
|
static |
Definition at line 1925 of file xmp_sidecar.cc.
References dt_exif_xmp_encode(), dt_free, dt_image_cache_get(), dt_image_cache_read_release(), IS_NULL_PTR, L, and value.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
|
static |
Definition at line 1949 of file xmp_sidecar.cc.
References _exif_xmp_append_history_hash(), dt_datetime_gtimespan_to_exif(), DT_DATETIME_LENGTH, dt_free, dt_free_gpointer(), DT_IMAGE_AUTO_PRESETS_APPLIED, dt_image_get_xmp_rating_from_flags(), dt_image_repository_get_xmp_row(), dt_image_repository_xmp_row_cleanup(), DT_IOP_ORDER_ANSEL_RAW, DT_IOP_ORDER_CUSTOM, dt_ioppr_get_iop_order_list(), dt_ioppr_get_iop_order_version(), dt_ioppr_has_multiple_instances(), dt_ioppr_serialize_text_iop_order_list(), dt_set_xmp_dt_history(), dt_set_xmp_dt_metadata(), dt_set_xmp_exif_geotag(), dt_tag_get_hierarchical(), dt_tag_get_list(), DT_XMP_EXIF_VERSION, FALSE, dt_image_xmp_row_t::filename, L, row, set_xmp_timestamps(), and TRUE.
Referenced by dt_exif_xmp_read_string(), and dt_exif_xmp_write_with_imgpath().
|
static |
Definition at line 2072 of file xmp_sidecar.cc.
References _exif_xmp_append_history_hash(), dt_datetime_gtimespan_to_exif(), DT_DATETIME_LENGTH, dt_free, dt_free_gpointer(), DT_IMAGE_AUTO_PRESETS_APPLIED, dt_image_get_xmp_rating_from_flags(), dt_image_repository_get_xmp_row(), dt_image_repository_xmp_row_cleanup(), DT_IOP_ORDER_ANSEL_RAW, DT_IOP_ORDER_CUSTOM, dt_ioppr_get_iop_order_list(), dt_ioppr_get_iop_order_version(), dt_ioppr_has_multiple_instances(), dt_ioppr_serialize_text_iop_order_list(), DT_META_DT_HISTORY, DT_META_EXIF, DT_META_GEOTAG, DT_META_HIERARCHICAL_TAG, DT_META_METADATA, DT_META_TAG, dt_remove_xmp_exif_geotag(), dt_set_xmp_dt_history(), dt_set_xmp_dt_metadata(), dt_set_xmp_exif_geotag(), dt_tag_get_hierarchical_export(), dt_tag_get_list_export(), DT_XMP_EXIF_VERSION, dt_image_xmp_row_t::filename, dt_export_metadata_t::flags, L, row, and TRUE.
Referenced by dt_exif_xmp_attach_export().
Definition at line 1217 of file xmp_sidecar.cc.
References L, MAX, history_entry_t::multi_priority, and history_entry_t::operation.
Read an XMP packet off disk into packet, FALSE if the file cannot be read.
Exiv2::readFile() would do this, but only through exiv2's own path handling – which is exactly the capability 0.28 dropped on Windows (see WIDEN() in metadata/exif_internal.h). These are small sidecar files and Ansel already has a reader that goes through g_fopen(), so there is no reason to route them back out through exiv2 and depend on something it may not be able to do. It also drops the 0.27-vs-0.28 fork over DataBuf's members that each of those call sites carried.
Definition at line 195 of file xmp_sidecar.cc.
References dt_free, dt_read_file(), IS_NULL_PTR, and L.
Referenced by dt_exif_xmp_attach_export(), and dt_exif_xmp_read_string().
|
static |
Definition at line 2288 of file xmp_sidecar.cc.
Referenced by dt_exif_xmp_attach_export().
Definition at line 1902 of file xmp_sidecar.cc.
Referenced by dt_set_xmp_dt_metadata().
|
static |
Definition at line 1681 of file xmp_sidecar.cc.
References dt_exif_xmp_encode(), dt_free, enabled, IS_NULL_PTR, key, L, and _xmp_history_ctx_t::xmpData.
Referenced by dt_set_xmp_dt_history().
|
static |
Definition at line 1639 of file xmp_sidecar.cc.
References dt_exif_xmp_encode(), dt_free, key, L, mask_id, mask_name, and _xmp_mask_ctx_t::xmpData.
Referenced by dt_set_xmp_dt_history().
Definition at line 1884 of file xmp_sidecar.cc.
References dt_conf_get_int(), dt_free, DT_METADATA_FLAG_HIDDEN, DT_METADATA_FLAG_PRIVATE, dt_metadata_get_key(), dt_metadata_get_name(), dt_metadata_get_type(), DT_METADATA_TYPE_INTERNAL, dt_util_dstrcat(), flag, L, name, value, and _xmp_metadata_ctx_t::xmpData.
Referenced by dt_set_xmp_dt_metadata().
|
static |
Definition at line 1191 of file xmp_sidecar.cc.
References add_mask_entries_to_db(), add_mask_entry_to_db(), DT_MASKS_GROUP, i, IS_NULL_PTR, L, mask_id, mask_entry_t::mask_nb, mask_entry_t::mask_points, mask_entry_t::mask_points_len, and mask_entry_t::mask_type.
Referenced by add_mask_entries_to_db(), and dt_exif_xmp_read().
|
static |
Definition at line 1155 of file xmp_sidecar.cc.
References mask_entry_t::already_added, dt_history_repository_write_mask_item(), L, mask_entry_t::mask_id, mask_entry_t::mask_name, mask_entry_t::mask_nb, mask_entry_t::mask_num, mask_entry_t::mask_points, mask_entry_t::mask_points_len, mask_entry_t::mask_src, mask_entry_t::mask_src_len, mask_entry_t::mask_type, mask_entry_t::mask_version, TRUE, and mask_entry_t::version.
Referenced by add_mask_entries_to_db(), add_non_clone_mask_entries_to_db(), and dt_exif_xmp_read().
|
static |
Definition at line 1184 of file xmp_sidecar.cc.
References add_mask_entry_to_db(), DT_MASKS_CLONE, DT_MASKS_NON_CLONE, mask_entry_t::mask_type, and value.
Referenced by dt_exif_xmp_read().
| int dt_exif_read_blob | ( | uint8_t ** | blob, |
| const char * | path, | ||
| const int32_t | imgid, | ||
| const int | sRGB, | ||
| const int | out_width, | ||
| const int | out_height, | ||
| const int | dng_mode | ||
| ) |
write exif to blob, return length in bytes. blob will be allocated by the function. sRGB should be true if sRGB colorspace is used as output.
Definition at line 270 of file xmp_sidecar.cc.
References darktable_package_string, dt_conf_get_int(), DT_DATETIME_EXIF_LENGTH, dt_datetime_img_to_exif(), DT_DATETIME_LENGTH, dt_datetime_now_to_exif(), dt_free, dt_free_gpointer(), dt_image_cache_get(), dt_image_cache_read_release(), dt_metadata_get(), dt_remove_exif_geotag(), dt_remove_exif_keys(), i, IS_NULL_PTR, L, res, sRGB, and WIDEN.
Referenced by dt_control_merge_hdr_job_run(), and dt_imageio_export_with_flags().
write xmp packet inside an image.
Definition at line 2332 of file xmp_sidecar.cc.
References _exif_get_exiv2_tag_type(), _exif_xmp_read_data_export(), _read_xmp_packet(), _remove_xmp_keys(), dt_exif_read_exif_tag(), dt_free, dt_image_full_path(), dt_image_path_append_version(), DT_META_EXIF, DT_META_GEOTAG, DT_PATH_MAX, dt_remove_exif_geotag(), dt_remove_exif_key(), dt_remove_iptc_key(), dt_remove_known_keys(), dt_remove_xmp_key(), dt_remove_xmp_keys(), dt_variables_expand(), dt_variables_params_destroy(), dt_variables_params_init(), dt_variables_set_tags_flags(), FALSE, i, IS_NULL_PTR, key, L, m, TRUE, type, and WIDEN.
Referenced by dt_imageio_export_with_flags().
| int dt_exif_xmp_read | ( | dt_image_t * | img, |
| const char * | filename, | ||
| const int | history_only | ||
| ) |
read xmp sidecar file.
Definition at line 1233 of file xmp_sidecar.cc.
References add_mask_entries_to_db(), add_mask_entry_to_db(), add_non_clone_mask_entries_to_db(), history_entry_t::blendop_params, history_entry_t::blendop_params_len, history_entry_t::blendop_version, dt_database_get_last_error(), dt_database_release_transaction, dt_database_rollback_transaction(), dt_database_start_transaction, dt_deprecated(), dt_exif_decode_xmp_data(), dt_exif_xmp_decode(), dt_free, dt_free_gpointer(), dt_history_repository_count_mask_items(), dt_history_repository_delete_history(), dt_history_repository_delete_masks_history(), dt_history_repository_get_next_num(), dt_history_repository_set_end(), dt_history_repository_shift_nums(), dt_history_repository_write_item(), DT_IMAGE_AUTO_PRESETS_APPLIED, DT_IMAGE_NO_LEGACY_PRESETS, DT_IOP_ORDER_ANSEL_RAW, DT_IOP_ORDER_LEGACY, dt_ioppr_deserialize_text_iop_order_list(), dt_ioppr_get_iop_order_link(), dt_ioppr_get_iop_order_list_version(), dt_ioppr_insert_missing_modules(), dt_ioppr_write_iop_order_list(), dt_sort_iop_list_by_order_f(), history_entry_t::enabled, FALSE, dt_image_t::flags, free_history_entry(), free_mask_entry(), dt_image_t::history_hash, dt_image_t::id, dt_iop_order_entry_t::instance, history_entry_t::iop_order, dt_iop_order_entry_t::iop_order_f, IS_NULL_PTR, L, dt_image_raw_parameters_t::legacy, dt_image_t::legacy_flip, MIN, history_entry_t::modversion, history_entry_t::multi_name, history_entry_t::multi_priority, history_entry_t::num, dt_iop_order_entry_t::o, history_entry_t::operation, dt_iop_order_entry_t::operation, out, history_entry_t::params, history_entry_t::params_len, read_history_v1(), read_history_v2(), read_masks(), read_masks_v3(), read_xmp_timestamps(), TRUE, dt_image_raw_parameters_t::user_flip, and WIDEN.
Referenced by _history_load_and_apply_apply(), _image_import_internal(), dt_image_read_duplicates(), and main().
| char * dt_exif_xmp_read_string | ( | const int32_t | imgid | ) |
get the xmp blob for imgid.
Definition at line 2213 of file xmp_sidecar.cc.
References _exif_xmp_read_data(), _read_xmp_packet(), dt_image_full_path(), dt_image_path_append_version(), DT_PATH_MAX, dt_remove_known_keys(), ERROR_CODE, FALSE, and L.
Referenced by write_image(), and write_image().
| int dt_exif_xmp_write_with_imgpath | ( | const dt_image_t * | image, |
| const char * | filename, | ||
| const char * | imgpath | ||
| ) |
Definition at line 2579 of file xmp_sidecar.cc.
References _exif_xmp_read_data(), dt_free, DT_METADATA_NOTICE_MESSAGE, dt_metadata_notify(), dt_read_file(), dt_remove_known_keys(), ERROR_CODE, dt_image_t::id, IS_NULL_PTR, L, and TRUE.
Referenced by _write_sidecar_file_from_image_locked(), and write_image().
|
static |
Definition at line 254 of file xmp_sidecar.cc.
References dt_remove_exif_keys(), and L.
Referenced by dt_exif_read_blob(), and dt_exif_xmp_attach_export().
|
static |
Definition at line 2306 of file xmp_sidecar.cc.
References key.
Referenced by dt_exif_xmp_attach_export().
|
static |
Definition at line 2319 of file xmp_sidecar.cc.
Referenced by dt_exif_xmp_attach_export().
|
static |
Definition at line 214 of file xmp_sidecar.cc.
References dt_xmp_keys, dt_xmp_keys_n, i, key, and L.
Referenced by dt_exif_xmp_attach_export(), dt_exif_xmp_read_string(), and dt_exif_xmp_write_with_imgpath().
|
static |
Definition at line 1822 of file xmp_sidecar.cc.
References dt_remove_xmp_keys(), and L.
Referenced by _exif_xmp_read_data_export(), and dt_set_xmp_exif_geotag().
|
static |
Definition at line 2275 of file xmp_sidecar.cc.
Referenced by dt_exif_xmp_attach_export().
|
static |
Definition at line 234 of file xmp_sidecar.cc.
Referenced by dt_exif_xmp_attach_export(), dt_remove_xmp_exif_geotag(), and set_xmp_timestamps().
|
static |
Definition at line 1730 of file xmp_sidecar.cc.
References _xmp_append_history(), _xmp_append_mask(), dt_history_repository_foreach_mask_item(), dt_history_repository_foreach_row(), L, and MIN.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
|
static |
Definition at line 1910 of file xmp_sidecar.cc.
References _xmp_append_colorlabel(), _xmp_append_metadata(), dt_colorlabel_repository_foreach(), dt_metadata_repository_foreach(), L, and v.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
|
static |
Definition at line 1836 of file xmp_sidecar.cc.
References double(), dt_free, dt_remove_xmp_exif_geotag(), and L.
Referenced by _exif_xmp_read_data(), and _exif_xmp_read_data_export().
Definition at line 683 of file xmp_sidecar.cc.
References history_entry_t::blendop_params, dt_free, history_entry_t::multi_name, history_entry_t::operation, and history_entry_t::params.
Referenced by dt_exif_xmp_read(), and read_history_v2().
| void free_mask_entry | ( | gpointer | data | ) |
Definition at line 975 of file xmp_sidecar.cc.
References dt_free, mask_entry_t::mask_name, mask_entry_t::mask_points, and mask_entry_t::mask_src.
Referenced by dt_exif_xmp_read(), read_masks(), and read_masks_v3().
|
static |
Definition at line 663 of file xmp_sidecar.cc.
References history_entry_t::blendop_params, history_entry_t::blendop_version, history_entry_t::enabled, history_entry_t::iop_order, IS_NULL_PTR, history_entry_t::modversion, history_entry_t::multi_name, history_entry_t::multi_priority, history_entry_t::operation, and history_entry_t::params.
|
static |
Definition at line 696 of file xmp_sidecar.cc.
References history_entry_t::blendop_version, dt_exif_xmp_decode(), enabled, and L.
Referenced by dt_exif_xmp_read().
|
static |
Definition at line 831 of file xmp_sidecar.cc.
References dt_exif_xmp_decode(), dt_free, free_history_entry(), history_entry_t::have_modversion, history_entry_t::have_operation, history_entry_t::have_params, key, L, n, and TRUE.
Referenced by dt_exif_xmp_read().
|
static |
Definition at line 984 of file xmp_sidecar.cc.
References dt_exif_xmp_decode(), free_mask_entry(), i, L, mask_entry_t::mask_id, mask_id, mask_entry_t::mask_name, mask_name, mask_entry_t::mask_nb, mask_entry_t::mask_points, mask_entry_t::mask_points_len, mask_entry_t::mask_src, mask_entry_t::mask_src_len, mask_entry_t::mask_type, mask_entry_t::mask_version, and mask_entry_t::version.
Referenced by dt_exif_xmp_read().
|
static |
Definition at line 1050 of file xmp_sidecar.cc.
References dt_exif_xmp_decode(), dt_free, free_mask_entry(), key, L, and n.
Referenced by dt_exif_xmp_read().
|
static |
Definition at line 1794 of file xmp_sidecar.cc.
References _convert_unix_to_gtimespan(), dt_image_t::change_timestamp, dt_image_t::export_timestamp, L, and dt_image_t::print_timestamp.
Referenced by dt_exif_xmp_read().
|
static |
Definition at line 1759 of file xmp_sidecar.cc.
References dt_image_timestamps_t::change_timestamp, dt_image_repository_get_timestamps(), dt_remove_xmp_keys(), dt_image_timestamps_t::export_timestamp, dt_image_timestamps_t::has_change, dt_image_timestamps_t::has_export, dt_image_timestamps_t::has_import, dt_image_timestamps_t::has_print, dt_image_timestamps_t::import_timestamp, L, and dt_image_timestamps_t::print_timestamp.
Referenced by _exif_xmp_read_data().
| const char* dt_xmp_keys[] |
Definition at line 166 of file xmp_sidecar.cc.
Referenced by dt_remove_known_keys().
|
static |
Definition at line 184 of file xmp_sidecar.cc.
Referenced by dt_remove_known_keys().