summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2012-12-27 20:29:37 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2012-12-27 20:29:37 +0100
commitd0599f8ab5c38e14845407dea4eef4d4957f9e28 (patch)
tree14d5636e8a4213c06ab4144e5ae32a88f4ddbc8b /src
parentdfb9d91c3342d9415a41e98d3a4af7d8c7472c6b (diff)
downloadcataract-d0599f8ab5c38e14845407dea4eef4d4957f9e28.tar.xz
Support external EXIF metadata
This brings an ability to specify external file to read EXIF/IPTC data from. The motivation was to work around RAW editors randomly stripping some EXIF blocks.
Diffstat (limited to 'src')
-rwxr-xr-xsrc/cgg-dirgen16
-rw-r--r--src/generators.c12
-rw-r--r--src/items.c5
-rw-r--r--src/items.h1
4 files changed, 31 insertions, 3 deletions
diff --git a/src/cgg-dirgen b/src/cgg-dirgen
index 0df3943..4cff755 100755
--- a/src/cgg-dirgen
+++ b/src/cgg-dirgen
@@ -23,6 +23,8 @@ PREVIEW_PATH="preview"
NO_FULLSIZE="no"
EXT_THUMB="no"
EXT_THUMB_PATH="thumbnails"
+EXT_EXIF="no"
+EXT_EXIF_PATH="exif"
print_help()
@@ -37,6 +39,8 @@ print_help()
echo " - deprecated, use global <nofullsize /> tag"
echo " -t, --thumbnails [dir] Use supplied thumbnails"
echo " - takes optional [dir] argument (default=\"thumbnails\")"
+ echo " -e, --exif [dir] Use external EXIF data (.exv file extension)"
+ echo " - takes optional [dir] argument (default=\"exif\")"
}
@@ -64,6 +68,14 @@ while [[ $1 = -* ]]; do
shift
fi
;;
+ -e|--exif)
+ EXT_EXIF="yes"
+ shift
+ if [[ ! $1 == -* && ! "x$1" == "x" ]]; then
+ EXT_EXIF_PATH="$1"
+ shift
+ fi
+ ;;
-h|--help|-\?)
print_help;
exit
@@ -93,10 +105,12 @@ XML_HEADER_STOP
for i in `find -L . -maxdepth 1 -type f -iname '*.jpg' -or -iname '*.jpeg' -or -iname '*.gif' -or -iname '*.png' | sort`; do
INCL="";
+ INCL_AFTER="";
if [[ ${PREVIEW} == "yes" ]]; then INCL=" preview=\"${PREVIEW_PATH}/`echo $i | cut -b 3-`\""; fi
if [[ ${EXT_THUMB} == "yes" ]]; then INCL+=" thumbnail=\"${EXT_THUMB_PATH}/`echo $i | cut -b 3-`\""; fi
if [[ ${NO_FULLSIZE} == "yes" ]]; then INCL+=">\n <nofullsize /"; fi
- echo -e " <item src=\"`echo $i | cut -b 3-`\"${INCL}>\n <title> </title>\n <title_description> </title_description>\n </item>\n";
+ if [[ ${EXT_EXIF} == "yes" ]]; then INCL_AFTER+=" <metadata>\n <external_exif src=\"${EXT_EXIF_PATH}/`echo ${i%.*}.exv | cut -b 3-`\" />\n </metadata>\n"; fi
+ echo -e " <item src=\"`echo $i | cut -b 3-`\"${INCL}>\n <title> </title>\n <title_description> </title_description>\n${INCL_AFTER} </item>\n";
done
cat << XML_FOOTER_STOP
diff --git a/src/generators.c b/src/generators.c
index ab7ab12..d5f1837 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -706,9 +706,17 @@ write_html_image (TGallerySetup *setup,
if (next_item && setup->preload)
get_image_paths (setup, parent_items, next_item, next_item_index, path_info, image_size, NULL, NULL, &preload_imgname);
- /* Get EXIF data from the original image */
+ /* Use external EXIF file if specified */
exif = NULL;
- if (img_orig_src) {
+ if (item->metadata_external_exif) {
+ s1 = g_build_filename (path_info->src_dir, item->metadata_external_exif, NULL);
+ exif = read_exif (s1);
+ if (exif == NULL)
+ log_error ("write_html_image: error getting exif data from file \"%s\"\n", s1);
+ g_free (s1);
+ }
+ /* Get EXIF data from the original image */
+ if (exif == NULL && img_orig_src) {
exif = read_exif (img_orig_src);
if (exif == NULL)
log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_orig_src);
diff --git a/src/items.c b/src/items.c
index 74cfb49..68ae66d 100644
--- a/src/items.c
+++ b/src/items.c
@@ -40,6 +40,7 @@ free_album_item (TIndexItem *item)
g_free (item->thumbnail);
g_free (item->preview);
g_free (item->border_style);
+ g_free (item->metadata_external_exif);
g_free (item);
}
@@ -215,6 +216,10 @@ parse_album_xml (const gchar *filename, TPathInfo *path_info)
g_free (s);
}
+ s = g_strdup_printf ("/gallery/items/*[%d]/metadata/external_exif", i + 1);
+ item->metadata_external_exif = xml_file_get_node_attribute (xml, s, "src");
+ g_free (s);
+
if (item->path || item->preview) {
g_ptr_array_add (index->items, item);
} else {
diff --git a/src/items.h b/src/items.h
index cef184c..2a7179c 100644
--- a/src/items.h
+++ b/src/items.h
@@ -71,6 +71,7 @@ typedef struct {
gchar *border_style;
TIndexItemType type;
gboolean hidden;
+ gchar *metadata_external_exif;
} TIndexItem;
typedef struct {