summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--generators.c4
-rw-r--r--jpeg-utils.cpp25
-rw-r--r--jpeg-utils.h6
-rw-r--r--sample/src/setup.xml4
-rw-r--r--setup.c4
-rw-r--r--setup.h1
6 files changed, 44 insertions, 0 deletions
diff --git a/generators.c b/generators.c
index b94a691..d26e4e7 100644
--- a/generators.c
+++ b/generators.c
@@ -163,6 +163,8 @@ generate_image (TGallerySetup *setup,
if (setup->verbose) printf (" done.\n");
g_free (big_src);
}
+ if (setup->erase_exif_thumbnail)
+ strip_thumbnail (big_dst);
g_free (big_dst);
if (! item->nofullsize)
@@ -175,6 +177,8 @@ generate_image (TGallerySetup *setup,
fprintf (stderr, "write_html_index: error copying original image %s\n", img_src_full);
else
if (setup->verbose) printf(" done.\n");
+ if (setup->erase_exif_thumbnail)
+ strip_thumbnail (orig_dst);
g_free (orig_dst);
}
}
diff --git a/jpeg-utils.cpp b/jpeg-utils.cpp
index b550b21..316cbd7 100644
--- a/jpeg-utils.cpp
+++ b/jpeg-utils.cpp
@@ -389,3 +389,28 @@ calculate_sizes (const unsigned long max_width, const unsigned long max_height,
}
}
+
+/*
+ * strip_thumbnail: strip thumbnail stored in EXIF table
+ */
+void
+strip_thumbnail (const char *filename)
+{
+ try
+ {
+ Exiv2::Image::AutoPtr image = Exiv2::ImageFactory::open(filename);
+ g_assert (image.get() != 0);
+
+ image->readMetadata();
+ Exiv2::ExifData &exifData = image->exifData();
+ if (! exifData.empty()) {
+ exifData.eraseThumbnail();
+ image->writeMetadata();
+ }
+ }
+ catch (Exiv2::AnyError& e)
+ {
+ fprintf (stderr, "strip_thumbnail: Caught Exiv2 exception: '%s'\n", e.what());
+ }
+}
+
diff --git a/jpeg-utils.h b/jpeg-utils.h
index aec1a96..7d05eab 100644
--- a/jpeg-utils.h
+++ b/jpeg-utils.h
@@ -83,6 +83,12 @@ void get_image_sizes (const char *img,
void calculate_sizes (const unsigned long max_width, const unsigned long max_height,
unsigned long *width, unsigned long *height);
+/*
+ * strip_thumbnail: strip thumbnail stored in EXIF table
+ */
+void strip_thumbnail (const char *filename);
+
+
#ifdef __cplusplus
}
diff --git a/sample/src/setup.xml b/sample/src/setup.xml
index f4ed85a..ef37f9a 100644
--- a/sample/src/setup.xml
+++ b/sample/src/setup.xml
@@ -35,6 +35,10 @@
<!-- titles are retrieved from the following fields (sorted by priority): -->
<!-- Iptc.Application2.Caption, Jpeg.Comment, Exif.Image.ImageDescription, Exif.Photo.UserComment -->
<use_iptc_exif value="yes" />
+
+ <!-- erase embedded thumbnail image (both from original and big images)? -->
+ <!-- (allowed values: "yes", "no") default = no -->
+ <erase_embed_thumbnail value="yes" />
</images>
<!-- META tags in html head section -->
diff --git a/setup.c b/setup.c
index 42846b5..f5b0384 100644
--- a/setup.c
+++ b/setup.c
@@ -119,6 +119,9 @@ parse_setup_xml (const char *filename, TGallerySetup *setup)
s = xml_file_get_node_attribute (xml, "/gallery_setup/images/use_iptc_exif", "value");
setup->use_iptc_exif = s ? strcasecmp (s, "yes") == 0 : FALSE; /* default to FALSE */
if (s) g_free (s);
+ s = xml_file_get_node_attribute (xml, "/gallery_setup/images/erase_embed_thumbnail", "value");
+ setup->erase_exif_thumbnail = s ? strcasecmp (s, "yes") == 0 : FALSE; /* default to FALSE */
+ if (s) g_free (s);
xml_parser_close (xml);
@@ -146,6 +149,7 @@ parse_setup_xml (const char *filename, TGallerySetup *setup)
printf("setup: meta_keywords = '%s'\n", setup->meta_keywords);
printf("setup: preload = %d\n", setup->preload);
printf("setup: use_iptc_exif = %d\n", setup->use_iptc_exif);
+ printf("setup: erase_exif_thumbnail = %d\n", setup->erase_exif_thumbnail);
#endif
return TRUE;
diff --git a/setup.h b/setup.h
index 6f5c55c..06afaeb 100644
--- a/setup.h
+++ b/setup.h
@@ -56,6 +56,7 @@ typedef struct {
gboolean preload;
gboolean use_iptc_exif;
+ gboolean erase_exif_thumbnail;
} TGallerySetup;