From d0599f8ab5c38e14845407dea4eef4d4957f9e28 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Thu, 27 Dec 2012 20:29:37 +0100 Subject: 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. --- sample/src/CIAF_1/exif/5l9a4978.exv | Bin 0 -> 44161 bytes sample/src/CIAF_1/img_1453b.jpg | 1 + sample/src/CIAF_1/index.xml | 13 +++++++++++++ src/cgg-dirgen | 16 +++++++++++++++- src/generators.c | 12 ++++++++++-- src/items.c | 5 +++++ src/items.h | 1 + 7 files changed, 45 insertions(+), 3 deletions(-) create mode 100644 sample/src/CIAF_1/exif/5l9a4978.exv create mode 120000 sample/src/CIAF_1/img_1453b.jpg diff --git a/sample/src/CIAF_1/exif/5l9a4978.exv b/sample/src/CIAF_1/exif/5l9a4978.exv new file mode 100644 index 0000000..f149f8c Binary files /dev/null and b/sample/src/CIAF_1/exif/5l9a4978.exv differ diff --git a/sample/src/CIAF_1/img_1453b.jpg b/sample/src/CIAF_1/img_1453b.jpg new file mode 120000 index 0000000..4b0b3c1 --- /dev/null +++ b/sample/src/CIAF_1/img_1453b.jpg @@ -0,0 +1 @@ +img_1453.jpg \ No newline at end of file diff --git a/sample/src/CIAF_1/index.xml b/sample/src/CIAF_1/index.xml index a73861e..9a00ad7 100644 --- a/sample/src/CIAF_1/index.xml +++ b/sample/src/CIAF_1/index.xml @@ -100,5 +100,18 @@ + + External EXIF metadata +
+ Photo editors and RAW workflow software usually strip big deal of metadata unknown to them. Things like camera makernote data are usually lost. Yet it may contain interesting information like lens used, crop factor/focal length converted to 35 mm film equivalent or even camera temperature.

+ Any format that the Exiv2 library is able to read can be used as a source of EXIF/IPTC information. Use cgg-dirgen to supply external metadata the same way like for supplied thumbnails. By default, the ".exv" file extension is used (default for exiv2 commandline tool).

+ That said, if you extract and save original metadata and supply them in gallery source XML files, you may be able to display more EXIF information at the end. It's wise to either point to an original RAW file or (to save space) use the exiv2 commandline tool to extract the metadata.
+ Example: exiv2 -eeic -f *.cr2 extracts EXIF, IPTC and JPEG Comment information to separate .exv files for all Canon CR2 files. + ]]>
+ + + +
+ 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 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 \n \n \n \n"; + if [[ ${EXT_EXIF} == "yes" ]]; then INCL_AFTER+=" \n \n \n"; fi + echo -e " \n \n \n${INCL_AFTER} \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 { -- cgit v1.2.3