From e420e9f3fbd5e758e4a1489766f74030a1b77b88 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 30 Dec 2008 16:21:41 +0100 Subject: Optional fallback to IPTC/EXIF captions and comments --- generators.c | 46 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 41 insertions(+), 5 deletions(-) (limited to 'generators.c') diff --git a/generators.c b/generators.c index 5eb7fde..8c8bc4e 100644 --- a/generators.c +++ b/generators.c @@ -588,6 +588,7 @@ write_html_image (TGallerySetup *setup, int i; char *s1, *s2, *s3, *s4; char *imgname, *preload_imgname; + char *title, *title_desc; char *b; gboolean res; int level; @@ -684,18 +685,52 @@ write_html_image (TGallerySetup *setup, continue; } + /* Get title and description from IPTC/EXIF/JPEG if not defined */ + title = g_strdup (item->title); + title_desc = g_strdup (item->title_description); + if (setup->use_iptc_exif && title == NULL && title_desc == NULL) { + if (exif->iptc_caption) + title = g_strdup (exif->iptc_caption); + if (exif->jpeg_comment) { + if (! title) + title = g_strdup (exif->jpeg_comment); + else + title_desc = g_strdup (exif->jpeg_comment); + } + if (exif->exif_imgdesc) { + if (! title) + title = g_strdup (exif->exif_imgdesc); +/* if (! title_desc) -- disabled + title_desc = g_strdup (exif->exif_imgdesc); */ + } + if (exif->exif_usercomment) { + if (! title) + title = g_strdup (exif->exif_usercomment); + if (! title_desc) + title_desc = g_strdup (exif->exif_usercomment); + } + /* Convert line breaks to be visible in the HTML code */ + if (title) { + str_replace (&title, "\r\n", "
", NULL); + str_replace (&title, "\n", "
", NULL); + } + if (title_desc) { + str_replace (&title_desc, "\r\n", "
", NULL); + str_replace (&title_desc, "\n", "
", NULL); + } + } /* Simple placeholders */ if (strstr (b, "")) str_replace (&b, "", imgname, NULL); - if (strstr (b, "") && item->title) { - s1 = g_strdup (item->title); + if (strstr (b, "") && title) { + s1 = g_strdup (title); fix_entities (&s1); str_replace (&b, "", s1, NULL); g_free (s1); } - if (strstr (b, "") && item->title_description) { - s1 = g_strdup (item->title_description); + if (strstr (b, "") && title_desc) { + s1 = g_strdup (title_desc); fix_entities (&s1); str_replace (&b, "", s1, NULL); g_free (s1); @@ -711,7 +746,6 @@ write_html_image (TGallerySetup *setup, g_free (s1); } if (strstr (b, "")) { -// s1 = g_strconcat (item->title, " (", imgname, ")", NULL); s1 = g_strdup (imgname); parent = parent_items; level = 0; @@ -882,6 +916,8 @@ write_html_image (TGallerySetup *setup, break; } free (b); + if (title) g_free (title); + if (title_desc) g_free (title_desc); } fclose (fout); -- cgit v1.2.3