diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-12-27 20:29:37 +0100 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2012-12-27 20:29:37 +0100 |
| commit | d0599f8ab5c38e14845407dea4eef4d4957f9e28 (patch) | |
| tree | 14d5636e8a4213c06ab4144e5ae32a88f4ddbc8b | |
| parent | dfb9d91c3342d9415a41e98d3a4af7d8c7472c6b (diff) | |
| download | cataract-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.
| -rw-r--r-- | sample/src/CIAF_1/exif/5l9a4978.exv | bin | 0 -> 44161 bytes | |||
| l--------- | sample/src/CIAF_1/img_1453b.jpg | 1 | ||||
| -rw-r--r-- | sample/src/CIAF_1/index.xml | 13 | ||||
| -rwxr-xr-x | src/cgg-dirgen | 16 | ||||
| -rw-r--r-- | src/generators.c | 12 | ||||
| -rw-r--r-- | src/items.c | 5 | ||||
| -rw-r--r-- | src/items.h | 1 |
7 files changed, 45 insertions, 3 deletions
diff --git a/sample/src/CIAF_1/exif/5l9a4978.exv b/sample/src/CIAF_1/exif/5l9a4978.exv Binary files differnew file mode 100644 index 0000000..f149f8c --- /dev/null +++ b/sample/src/CIAF_1/exif/5l9a4978.exv 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 @@ <!-- Captions should be retrieved from IPTC/EXIF --> </item> + <item src="img_1453b.jpg"> + <title>External EXIF metadata</title> + <title_description><![CDATA[This item uses external EXIF metadata, in this case supplied from a completely different picture.<br/><br/> + Photo editors and RAW workflow software usually strip big deal of metadata unknown to them. Things like <a href="http://exiv2.org/makernote.html">camera makernote</a> 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.<br/><br/> + Any format that the Exiv2 library is able to read can be used as a source of EXIF/IPTC information. Use <code>cgg-dirgen</code> to supply external metadata the same way like for supplied thumbnails. By default, the "<code>.exv</code>" file extension is used (default for <code>exiv2</code> commandline tool).<br/><br/> + 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 <code>exiv2</code> commandline tool to extract the metadata.<br/> + Example: <code>exiv2 -eeic -f *.cr2</code> extracts EXIF, IPTC and JPEG Comment information to separate .exv files for all Canon CR2 files. + ]]></title_description> + <metadata> + <external_exif src="exif/5l9a4978.exv" /> + </metadata> + </item> + </items> </gallery> 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 { |
