summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/generators.c5
-rw-r--r--src/jpeg-utils.cpp35
-rw-r--r--src/jpeg-utils.h5
-rw-r--r--templates/styles.css4
-rw-r--r--templates/template_picture.html12
5 files changed, 59 insertions, 2 deletions
diff --git a/src/generators.c b/src/generators.c
index 1d05eea..5fe87fe 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -707,6 +707,11 @@ write_html_image (TGallerySetup *setup,
if (exif == NULL)
log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_dst);
}
+ /* Test for basic EXIF keys presence */
+ if (exif != NULL && exif_has_key (exif, EXIF_APERTURE) &&
+ exif_has_key (exif, EXIF_FOCAL_LENGTH) &&
+ exif_has_key (exif, EXIF_EXPOSURE))
+ g_hash_table_replace (defines, g_strdup ("HAS_EXIF"), g_strdup (""));
/* Retrieve image sizes of preview and original image */
get_image_sizes (img_dst, &img_w, &img_h, setup->autorotate);
diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp
index 031ecc0..389b8e4 100644
--- a/src/jpeg-utils.cpp
+++ b/src/jpeg-utils.cpp
@@ -197,6 +197,41 @@ get_exif_data_fixed (ExifData *exif, const gchar *key)
return get_exif_data (exif, key);
}
+/*
+ * Returns TRUE if the image contains the key specified
+ */
+gboolean
+exif_has_key (ExifData *exif, const gchar *key)
+{
+ g_return_val_if_fail (exif != NULL, FALSE);
+ g_return_val_if_fail (key != NULL, FALSE);
+
+ try {
+ if (g_strcmp0 (key, JPEG_COMMENT) == 0) {
+ return (! exif->image->comment().empty());
+ }
+
+ if (g_str_has_prefix (key, "Exif.")) {
+ Exiv2::ExifData &exifData = exif->image->exifData();
+ if (! exifData.empty()) {
+ return (! exifData[key].toString().empty());
+ }
+ }
+
+ if (g_str_has_prefix (key, "Iptc.")) {
+ Exiv2::IptcData &iptcData = exif->image->iptcData();
+ if (! iptcData.empty()) {
+ return (! iptcData[key].toString().empty());
+ }
+ }
+
+ return FALSE;
+ }
+ catch (...) {
+ return FALSE;
+ }
+}
+
static void
autorotate_image (MagickWand *magick_wand)
diff --git a/src/jpeg-utils.h b/src/jpeg-utils.h
index 05a6a49..7cec3a7 100644
--- a/src/jpeg-utils.h
+++ b/src/jpeg-utils.h
@@ -62,6 +62,11 @@ void exif_data_free (ExifData *data);
gchar * get_exif_data (ExifData *exif, const gchar *key);
gchar * get_exif_data_fixed (ExifData *exif, const gchar *key);
+/*
+ * Returns TRUE if the image contains the key specified
+ */
+gboolean exif_has_key (ExifData *exif, const gchar *key);
+
/*
* resize_image: resize image pointed by src and save result to dst
diff --git a/templates/styles.css b/templates/styles.css
index b96f19f..ea337f9 100644
--- a/templates/styles.css
+++ b/templates/styles.css
@@ -175,6 +175,10 @@ div.exif td {
font-weight: bold;
}
+div.no_exif {
+ padding: 1em 0 0 2.6em;
+ font-size: 80%;
+}
/****** GENERAL CLASSES ******/
div.position_marker {
diff --git a/templates/template_picture.html b/templates/template_picture.html
index 07c79ec..d164b6d 100644
--- a/templates/template_picture.html
+++ b/templates/template_picture.html
@@ -20,7 +20,9 @@
<span class="navposspacer"></span>
<a href="$(LINK_PREV)">&lt; Previous</a> :: <a href="$(LINK_NEXT)">Next &gt;</a>
</div>
- <div class="navexif">ISO <!-- $(get_exif_value_fixed("Exif.Photo.ISOSpeedRatings")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.ExposureTime")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.FNumber")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.FocalLength")) --></div>
+ <!-- $(ifdef(HAS_EXIF)) -->
+ <div class="navexif">ISO <!-- $(get_exif_value_fixed("Exif.Photo.ISOSpeedRatings")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.ExposureTime")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.FNumber")) --> :: <!-- $(get_exif_value_fixed("Exif.Photo.FocalLength")) --></div>
+ <!-- $(endif(HAS_EXIF)) -->
</div>
@@ -45,7 +47,8 @@
<!-- ## EXIF -->
<div class="exif">
<div id="exif_table" style="display: none;">
- :: <a href="javascript: set_exif_table_visibility('no'); write_exif_table_cookie('no');">Hide EXIF</a>
+ :: <a href="javascript: set_exif_table_visibility('no'); write_exif_table_cookie('no');">Hide EXIF</a><br/>
+ <!-- $(ifdef(HAS_EXIF)) -->
<table><tbody>
<tr><td>Date: </td> <td><!-- $(get_exif_value_fixed("Exif.Photo.DateTimeOriginal")) --></td></tr>
<tr><td>Camera: </td> <td><!-- $(get_exif_value_fixed("Exif.Image.Model")) --></td></tr>
@@ -55,6 +58,11 @@
<tr><td>Exposure time: </td> <td><!-- $(get_exif_value_fixed("Exif.Photo.ExposureTime")) --></td></tr>
<tr><td>Flash: </td> <td><!-- $(get_exif_value_fixed("Exif.Photo.Flash")) --></td></tr>
</tbody></table>
+ <!-- $(else(HAS_EXIF)) -->
+ <div class="no_exif">
+ No EXIF information available.
+ </div>
+ <!-- $(endif(HAS_EXIF)) -->
</div>
<div id="exif_line" style="display: block;">
:: <a href="javascript: set_exif_table_visibility('yes'); write_exif_table_cookie('yes');">Show EXIF</a>