diff options
| -rw-r--r-- | generators.c | 46 | ||||
| -rw-r--r-- | sample/src/CIAF_1/img_1453.jpg | bin | 0 -> 261710 bytes | |||
| -rw-r--r-- | sample/src/CIAF_1/index.xml | 4 | ||||
| -rw-r--r-- | sample/src/setup.xml | 7 | ||||
| -rw-r--r-- | setup.c | 5 | ||||
| -rw-r--r-- | setup.h | 1 |
6 files changed, 58 insertions, 5 deletions
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", "<br />", NULL); + str_replace (&title, "\n", "<br />", NULL); + } + if (title_desc) { + str_replace (&title_desc, "\r\n", "<br />", NULL); + str_replace (&title_desc, "\n", "<br />", NULL); + } + } /* Simple placeholders */ if (strstr (b, "<!-- $(FILE_NAME) -->")) str_replace (&b, "<!-- $(FILE_NAME) -->", imgname, NULL); - if (strstr (b, "<!-- $(TITLE) -->") && item->title) { - s1 = g_strdup (item->title); + if (strstr (b, "<!-- $(TITLE) -->") && title) { + s1 = g_strdup (title); fix_entities (&s1); str_replace (&b, "<!-- $(TITLE) -->", s1, NULL); g_free (s1); } - if (strstr (b, "<!-- $(DESCRIPTION) -->") && item->title_description) { - s1 = g_strdup (item->title_description); + if (strstr (b, "<!-- $(DESCRIPTION) -->") && title_desc) { + s1 = g_strdup (title_desc); fix_entities (&s1); str_replace (&b, "<!-- $(DESCRIPTION) -->", s1, NULL); g_free (s1); @@ -711,7 +746,6 @@ write_html_image (TGallerySetup *setup, g_free (s1); } if (strstr (b, "<!-- $(NAV_BAR) -->")) { -// 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); diff --git a/sample/src/CIAF_1/img_1453.jpg b/sample/src/CIAF_1/img_1453.jpg Binary files differnew file mode 100644 index 0000000..06b549d --- /dev/null +++ b/sample/src/CIAF_1/img_1453.jpg diff --git a/sample/src/CIAF_1/index.xml b/sample/src/CIAF_1/index.xml index 3440c74..7e89297 100644 --- a/sample/src/CIAF_1/index.xml +++ b/sample/src/CIAF_1/index.xml @@ -83,5 +83,9 @@ <title_description>This item uses supplied thumbnail</title_description> </item> + <item src="img_1453.jpg"> + <!-- Captions should be retrieved from IPTC/EXIF --> + </item> + </items> </gallery> diff --git a/sample/src/setup.xml b/sample/src/setup.xml index af2bd9e..f4ed85a 100644 --- a/sample/src/setup.xml +++ b/sample/src/setup.xml @@ -28,6 +28,13 @@ <border style="border_single" /> <!-- preload next image (allowed values: "yes", "no") default = yes --> <preload value="yes" /> + + <!-- get image title and description from IPTC and EXIF as a fallback --> + <!-- if not overriden by <title> and <title_description> tags --> + <!-- (allowed values: "yes", "no") default = no --> + <!-- 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" /> </images> <!-- META tags in html head section --> @@ -116,6 +116,9 @@ parse_setup_xml (const char *filename, TGallerySetup *setup) s = xml_file_get_node_attribute (xml, "/gallery_setup/images/preload", "value"); setup->preload = s ? strcasecmp (s, "yes") == 0 : TRUE; /* default to TRUE */ if (s) g_free (s); + 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); xml_parser_close (xml); @@ -141,6 +144,8 @@ parse_setup_xml (const char *filename, TGallerySetup *setup) printf("setup: meta_author = '%s'\n", setup->meta_author); printf("setup: meta_description = '%s'\n", setup->meta_description); 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); #endif return TRUE; @@ -55,6 +55,7 @@ typedef struct { char *border_style; gboolean preload; + gboolean use_iptc_exif; } TGallerySetup; |
