summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--sample/src/CIAF_1/index.xml9
-rw-r--r--sample/src/entities/index.xml4
-rw-r--r--sample/src/setup.xml6
-rw-r--r--src/cgg.c3
-rw-r--r--src/generators.c107
-rw-r--r--src/items.c40
-rw-r--r--src/items.h11
-rw-r--r--src/setup.c14
-rw-r--r--src/setup.h2
9 files changed, 45 insertions, 151 deletions
diff --git a/sample/src/CIAF_1/index.xml b/sample/src/CIAF_1/index.xml
index cf53d61..1172b33 100644
--- a/sample/src/CIAF_1/index.xml
+++ b/sample/src/CIAF_1/index.xml
@@ -14,8 +14,6 @@
]]>
</footnote>
- <!-- legacy behaviour: you can override global settings in each album (applies only to the "preview" image size): -->
- <images quality="60" landscape_w="640" landscape_h="480" portrait_w="480" portrait_h="640" />
<!-- override global preview image border style -->
<border style="border_none" />
@@ -55,11 +53,6 @@
<interspace><![CDATA[This is so-called intespace - simple paragraph or a block with an additional information to the section. This may be used with &lt;separator&gt; but not necessarily, interspace can stand alone between items in the album. Useful for links or few senteces to separated topic.]]></interspace>
- <item preview="preview/img_6802d.jpg">
- <title>Photo title</title>
- <title_description>This photo doesn't contain link to original image nor the src parameter, EXIF data are extracted from the preview image.</title_description>
- </item>
-
<item>
<title>Invalid item</title>
<title_description>Invalid item (no src specified), will be skipped.</title_description>
@@ -96,7 +89,7 @@
<separator>Misc.</separator>
- <item preview="preview/img_6802g.jpg" thumbnail="thumbnails/gallery_thumbnails.gif">
+ <item src="preview/img_6802g.jpg" thumbnail="thumbnails/gallery_thumbnails.gif">
<title>Custom thumbnail</title>
<title_description>This item uses supplied thumbnail</title_description>
</item>
diff --git a/sample/src/entities/index.xml b/sample/src/entities/index.xml
index 44776ca..6761015 100644
--- a/sample/src/entities/index.xml
+++ b/sample/src/entities/index.xml
@@ -20,12 +20,12 @@
</general>
<items>
- <item preview="preview/img_6802.jpg">
+ <item src="preview/img_6802.jpg">
<title>Entities &#8594; '&amp;' "&amp;copy;"</title>
<title_description>Entities &#8594; '&amp;' "&amp;copy;"</title_description>
</item>
- <item preview="preview/img_6802b.jpg">
+ <item src="preview/img_6802b.jpg">
<title><![CDATA[Entities &#8594; '&amp;' "&copy;" &lt; <b>ahoj!</b> <!-- comment <b>neco</b> -->]]></title>
<title_description><![CDATA[Entities &#8594; '&amp;' "&copy;" &lt; <b>ahoj!</b> <!-- comment <b>neco</b> -->]]></title_description>
</item>
diff --git a/sample/src/setup.xml b/sample/src/setup.xml
index a67923d..54bfb5b 100644
--- a/sample/src/setup.xml
+++ b/sample/src/setup.xml
@@ -36,12 +36,6 @@
<!-- (think of source RAW file vs. processed JPEG image differences) -->
<write_supplied_exif value="no" />
- <!-- don't copy full size (original) images -->
- <!-- <nofullsize/> can be used globally for whole gallery, -->
- <!-- for full album or selectively for each image -->
- <!-- - override with <fullsize/> for album or for separate image -->
-<!-- <nofullsize /> -->
-
<!-- autorotate input images according to EXIF information, unless -->
<!-- provided in the album source file (copy mode) (default = yes) -->
<autorotate value="yes" />
diff --git a/src/cgg.c b/src/cgg.c
index 146c687..13a7389 100644
--- a/src/cgg.c
+++ b/src/cgg.c
@@ -42,7 +42,6 @@ static gchar *source_dir = NULL;
static gchar *dst_dir = NULL;
static gboolean verbose = FALSE;
static gboolean update = FALSE;
-static gboolean fullsize = FALSE;
static gboolean dont_strip_unused_tags = FALSE;
static gboolean warn_resize = FALSE;
static int jobs = 0;
@@ -68,7 +67,6 @@ parse_cmd (int argc, char *argv[])
#endif
"N" },
{ "update", 'u', 0, G_OPTION_ARG_NONE, &update, "Update the output structure", NULL },
- { "fullsize", 'f', 0, G_OPTION_ARG_NONE, &fullsize, "Override the nofullsize switch and generate full gallery", NULL },
{ "debug-dont-strip-unused-tags", 0, 0, G_OPTION_ARG_NONE, &dont_strip_unused_tags, "Don't strip unused/unknown template tags", NULL },
{ "debug-warn-resize", 0, 0, G_OPTION_ARG_NONE, &warn_resize, "Warn when image is being resized", NULL },
{ NULL }
@@ -217,7 +215,6 @@ main (int argc, char* argv[])
/* Start building the gallery tree */
setup->verbose = verbose;
setup->update_mode = update;
- setup->override_nofullsize = fullsize;
setup->strip_unused_tags = ! dont_strip_unused_tags;
setup->warn_resize = warn_resize;
diff --git a/src/generators.c b/src/generators.c
index 7fad313..b83382a 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -37,11 +37,6 @@
#include "generators.h"
-#define IS_NOFULLSIZE(item,parent_items,setup) \
- (! item->force_fullsize && ! setup->override_nofullsize && \
- (! parent_items->fullsize || item->force_nofullsize) && \
- (item->force_nofullsize || parent_items->nofullsize || setup->nofullsize))
-
#define BUFFER_SIZE 65536 /* line cannot be longer than this */
#define POSITION_MARKER_FMT "i%d"
@@ -201,11 +196,8 @@ get_image_paths (TGallerySetup *setup,
gchar **full_img_dst,
gchar **page_img_dst)
{
- gboolean nofullsize;
- gboolean is_original;
gchar *s1, *s2, *s3;
gchar *target_image_dir;
- TImageSize *src_image_size;
if (full_img_src)
*full_img_src = NULL;
@@ -214,52 +206,28 @@ get_image_paths (TGallerySetup *setup,
if (page_img_dst)
*page_img_dst = NULL;
- nofullsize = IS_NOFULLSIZE (item, items, setup);
- is_original = g_ascii_strcasecmp ("original", image_size->name) == 0;
-
/* ignore combinations that are not valid */
if ((items->type == GALLERY_TYPE_INDEX && ! image_size->is_thumbnail) ||
(image_size->is_thumbnail && item->hidden) ||
(image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX && (item->thumbnail == NULL || strlen (item->thumbnail) == 0)))
return;
- if (is_original && nofullsize && image_size->fallback_size == NULL) {
- log_error ("Requested legacy nofullsize flag but fallback image size not defined.\n");
- return;
- }
s1 = NULL;
if (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX)
s1 = item->thumbnail;
- if (s1 == NULL && ! is_original && item->image_sizes != NULL)
+ if (s1 == NULL && item->image_sizes != NULL)
s1 = g_hash_table_lookup (item->image_sizes, image_size->name);
- if (s1 == NULL && is_original && ! nofullsize)
- s1 = item->path;
-
/* go through the fallback */
while (s1 == NULL && image_size->fallback_size != NULL) {
image_size = lookup_image_size_for_name (setup, image_size->fallback_size);
- is_original = g_ascii_strcasecmp ("original", image_size->name) == 0;
- if (is_original)
- s1 = nofullsize ? NULL : item->path;
- else
- s1 = item->image_sizes ? g_hash_table_lookup (item->image_sizes, image_size->name) : NULL;
+ s1 = item->image_sizes ? g_hash_table_lookup (item->image_sizes, image_size->name) : NULL;
}
- /* we have reached our target image size, s1 == NULL means the image should be resized from the original size */
- if (s1 == NULL) {
- s1 = item->path; /* nofullsize is handled by the fallback */
- if (s1 == NULL) {
- /* no original image available, try fallback as a last resort (i.e. preview fallback) */
- src_image_size = lookup_image_size_for_name (setup, "original");
- while (s1 == NULL && src_image_size->fallback_size != NULL) {
- src_image_size = lookup_image_size_for_name (setup, src_image_size->fallback_size);
- if (item->image_sizes != NULL)
- s1 = g_hash_table_lookup (item->image_sizes, src_image_size->name);
- }
- }
- }
+ /* we have reached our target image size, s1 == NULL means the image should be resized from the source image */
+ if (s1 == NULL)
+ s1 = item->path;
if (s1 == NULL) {
log_error ("Unable to find image source for item #%d (\"%s\") for image size \"%s\"\n", get_item_index (items, item), item->title, image_size->name);
@@ -360,7 +328,6 @@ static gboolean
have_image_size_cb (gchar **args, gpointer user_data)
{
struct HaveImageSizeData *data = user_data;
- gboolean is_original;
g_return_val_if_fail (g_strv_length (args) != 2, FALSE); /* incl. trailing NULL */
@@ -368,17 +335,12 @@ have_image_size_cb (gchar **args, gpointer user_data)
if (! lookup_image_size_for_name (data->setup, *args))
return FALSE;
- is_original = g_ascii_strcasecmp ("original", *args) == 0;
-
- /* no custom image sizes defined for the particular item */
- if (! is_original && ! data->item->image_sizes)
- return FALSE;
-
- if (! is_original && data->item->image_sizes && g_hash_table_lookup (data->item->image_sizes, *args))
+ if (data->item->image_sizes && g_hash_table_lookup (data->item->image_sizes, *args))
return TRUE;
- if (is_original && data->item->path && ! IS_NOFULLSIZE (data->item, data->items, data->setup))
- return TRUE;
+ /* FIXME: rework this */
+/* if (data->item->path)
+ return TRUE; */
return FALSE;
}
@@ -387,7 +349,6 @@ static gboolean
have_album_image_size_cb (gchar **args, gpointer user_data)
{
struct HaveImageSizeData *data = user_data;
- gboolean is_original;
TIndexItem *iter_item;
int i;
@@ -397,18 +358,17 @@ have_album_image_size_cb (gchar **args, gpointer user_data)
if (! lookup_image_size_for_name (data->setup, *args))
return FALSE;
- is_original = g_ascii_strcasecmp ("original", *args) == 0;
-
for (i = 0; i < data->items->items->len; i++) {
iter_item = g_ptr_array_index (data->items->items, i);
if (iter_item == NULL || iter_item->type != INDEX_ITEM_TYPE_PICTURE || iter_item->hidden)
continue;
- if (! is_original && iter_item->image_sizes && g_hash_table_lookup (iter_item->image_sizes, *args))
+ if (iter_item->image_sizes && g_hash_table_lookup (iter_item->image_sizes, *args))
return TRUE;
- if (is_original && iter_item->path && ! IS_NOFULLSIZE (iter_item, data->items, data->setup))
- return TRUE;
+ /* FIXME: rework this */
+/* if (iter_item->path)
+ return TRUE; */
}
return FALSE;
@@ -426,14 +386,11 @@ generate_image (TGallerySetup *setup,
gboolean query_update)
{
gboolean res;
- gboolean is_preview;
- gboolean is_original;
gchar *img_src;
gchar *img_dst;
unsigned long img_w, img_h;
unsigned long src_img_w, src_img_h;
unsigned long tmpw, tmph;
- int quality;
GList *l;
TImageSize *image_size;
ExifData *exif_data;
@@ -443,14 +400,8 @@ generate_image (TGallerySetup *setup,
for (l = g_list_first (setup->design->image_sizes); l; l = g_list_next (l)) {
image_size = l->data;
- is_original = g_ascii_strcasecmp ("original", image_size->name) == 0;
- is_preview = g_ascii_strcasecmp ("preview", image_size->name) == 0;
-
- if (is_original && (IS_NOFULLSIZE (item, items, setup) || item->path == NULL))
- continue;
-
/* fallback mode, don't generate any image and use different image size */
- if (image_size->fallback_size != NULL && ! is_original && (! item->image_sizes || g_hash_table_lookup (item->image_sizes, image_size->name) == NULL))
+ if (image_size->fallback_size != NULL && (item->image_sizes == NULL || g_hash_table_lookup (item->image_sizes, image_size->name) == NULL))
continue;
get_image_paths (setup, items, item, path_info, image_size, &img_src, &img_dst, NULL);
@@ -470,7 +421,7 @@ generate_image (TGallerySetup *setup,
res = res || needs_update (img_src, img_dst);
if (! query_update) {
/* Determine whether to perform file copy or resize */
- if (! image_size->is_thumbnail && image_size->no_resize && ((is_original && item->path) || (item->image_sizes && g_hash_table_lookup (item->image_sizes, image_size->name)))) {
+ if (! image_size->is_thumbnail && image_size->no_resize && (! item->image_sizes || (item->image_sizes && g_hash_table_lookup (item->image_sizes, image_size->name)))) {
if (! copy_file (img_src, img_dst))
log_error (" Error copying image %s to %s\n", img_src, img_dst);
}
@@ -496,40 +447,21 @@ generate_image (TGallerySetup *setup,
else {
img_w = src_img_w;
img_h = src_img_h;
- /* Only the "preview" size is affected by legacy item and album overrides */
- if (is_preview) {
- tmpw = get_prop_int (items, item, PROP_WIDTH, img_w);
- tmph = get_prop_int (items, item, PROP_HEIGHT, img_h);
- calculate_sizes (tmpw, tmph, &img_w, &img_h);
- }
/* Calculate sizes */
if (img_w > img_h) {
tmpw = image_size->landscape_width;
tmph = image_size->landscape_height;
- if (is_preview) {
- tmpw = get_prop_int (items, item, PROP_LANDSCAPE_W, tmpw);
- tmph = get_prop_int (items, item, PROP_LANDSCAPE_H, tmph);
- }
} else {
tmpw = image_size->portrait_width;
tmph = image_size->portrait_height;
- if (is_preview) {
- tmpw = get_prop_int (items, item, PROP_PORTRAIT_W, tmpw);
- tmph = get_prop_int (items, item, PROP_PORTRAIT_H, tmph);
- }
}
calculate_sizes (tmpw, tmph, &img_w, &img_h);
}
- /* Calculate quality */
- if (is_preview)
- quality = get_prop_int (items, item, PROP_QUALITY, image_size->quality);
- else
- quality = image_size->quality;
/* Perform resize and strip */
if (setup->warn_resize && ! image_size->is_thumbnail)
printf (" Warning: resizing image %s from %lux%lu to %lux%lu\n", img_src, src_img_w, src_img_h, img_w, img_h);
- if (! resize_image (img_src, img_dst, img_w, img_h, quality, image_size->is_thumbnail, setup->autorotate, exif_data))
+ if (! resize_image (img_src, img_dst, img_w, img_h, image_size->quality, image_size->is_thumbnail, setup->autorotate, exif_data))
log_error (" Error resizing image %s\n", img_src);
} else {
log_error ("generate_image: image %s sizes are %lux%lu\n", img_src, src_img_w, src_img_h);
@@ -932,8 +864,11 @@ process_img_item (TGallerySetup *setup,
exif = get_img_exif_data (setup, path_info, items, item, image_size);
/* TODO: legacy stuff, subject to removal */
- orig_image_size = lookup_image_size_for_name (setup, "original");
- if (orig_image_size != NULL && img_orig_dst != NULL && ! IS_NOFULLSIZE (item, items, setup)) {
+ orig_image_size = NULL;
+ /* Take the last image size from the sorted list */
+ if (g_list_length (setup->design->image_sizes) > 0)
+ orig_image_size = (TImageSize *) g_list_last (setup->design->image_sizes);
+ if (orig_image_size != NULL) {
img_orig_dst = img_orig_dst_page = NULL;
get_image_paths (setup, items, item, path_info, orig_image_size, NULL, &img_orig_dst, &img_orig_dst_page);
get_image_sizes (img_orig_dst, &img_orig_w, &img_orig_h, setup->autorotate);
diff --git a/src/items.c b/src/items.c
index acd4373..27ab57e 100644
--- a/src/items.c
+++ b/src/items.c
@@ -163,12 +163,6 @@ parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_in
g_free (s);
}
- prop_xml_attr_long (index->properties, PROP_QUALITY, xml, "/gallery/general/images", "quality");
- prop_xml_attr_long (index->properties, PROP_LANDSCAPE_W, xml, "/gallery/general/images", "landscape_w");
- prop_xml_attr_long (index->properties, PROP_LANDSCAPE_H, xml, "/gallery/general/images", "landscape_h");
- prop_xml_attr_long (index->properties, PROP_PORTRAIT_W, xml, "/gallery/general/images", "portrait_w");
- prop_xml_attr_long (index->properties, PROP_PORTRAIT_H, xml, "/gallery/general/images", "portrait_h");
-
prop_xml_attr (index->properties, PROP_BORDER_STYLE, xml, "/gallery/general/border", "style");
index->meta_author = xml_file_get_node_value (xml, "/gallery/general/meta/author/text()");
index->meta_description = xml_file_get_node_value (xml, "/gallery/general/meta/description/text()");
@@ -201,9 +195,6 @@ parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_in
}
- index->nofullsize = xml_file_get_node_present (xml, "/gallery/general/nofullsize");
- index->fullsize = xml_file_get_node_present (xml, "/gallery/general/fullsize");
-
/* News records */
if (news_feed) {
count = xml_file_node_get_children_count (xml, "/gallery/general/news");
@@ -270,9 +261,6 @@ parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_in
item->path = xml_file_get_node_attribute (xml, s, "path");
else
item->path = xml_file_get_node_attribute (xml, s, "src");
- prop_xml_attr_long (item->properties, PROP_QUALITY, xml, s, "quality");
- prop_xml_attr_long (item->properties, PROP_WIDTH, xml, s, "width");
- prop_xml_attr_long (item->properties, PROP_HEIGHT, xml, s, "height");
prop_xml_attr (item->properties, PROP_BORDER_STYLE, xml, s, "border");
/* custom image size attributes */
@@ -296,19 +284,15 @@ parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_in
item->title_description = xml_file_get_node_value (xml, s);
g_free (s);
- if (index->type == GALLERY_TYPE_INDEX) {
- s = g_strdup_printf ("/gallery/items/*[%d]/thumbnail", i + 1);
+ s = g_strdup_printf ("/gallery/items/*[%d]/thumbnail", i + 1);
+ if (index->type == GALLERY_TYPE_INDEX)
item->thumbnail = xml_file_get_node_attribute (xml, s, "src");
- g_free (s);
- }
-
- s = g_strdup_printf ("/gallery/items/*[%d]/nofullsize", i + 1);
- item->force_nofullsize = (xml_file_get_node_present (xml, s) || item->path == NULL);
- g_free (s);
-
- s = g_strdup_printf ("/gallery/items/*[%d]/fullsize", i + 1);
- item->force_fullsize = xml_file_get_node_present (xml, s);
+ s2 = xml_file_get_node_attribute (xml, s, "crop");
g_free (s);
+ if (s2 != NULL) {
+ properties_table_add_int (item->properties, PROP_THUMB_CROP_HINT, parse_thumbnail_crop_hint (s2));
+ g_free (s2);
+ }
s = g_strdup_printf ("/gallery/items/*[%d]/hidden", i + 1);
item->hidden = (xml_file_get_node_present (xml, s));
@@ -365,15 +349,7 @@ parse_album_xml (TGallerySetup *setup, const gchar *filename, TPathInfo *path_in
}
g_free (s);
- s = g_strdup_printf ("/gallery/items/*[%d]/thumbnail", i + 1);
- s2 = xml_file_get_node_attribute (xml, s, "crop");
- g_free (s);
- if (s2 != NULL) {
- properties_table_add_int (item->properties, PROP_THUMB_CROP_HINT, parse_thumbnail_crop_hint (s2));
- g_free (s2);
- }
-
- if (item->path || item->image_sizes) {
+ if (item->path) {
g_ptr_array_add (index->items, item);
} else {
log_error ("%s: No image src specified (title = '%s'), skipping!\n", filename, item->title);
diff --git a/src/items.h b/src/items.h
index e62bc02..2d0df59 100644
--- a/src/items.h
+++ b/src/items.h
@@ -62,8 +62,6 @@ typedef struct {
gchar *meta_author;
gchar *meta_description;
gchar *meta_keywords;
- gboolean nofullsize;
- gboolean fullsize;
gchar **extra_files;
gchar *auth_realm;
gchar *auth_username;
@@ -79,8 +77,6 @@ typedef struct {
gchar *title_description;
gchar *thumbnail; /* index pages */
GHashTable *image_sizes;
- gboolean force_nofullsize;
- gboolean force_fullsize;
gboolean hidden;
gchar *metadata_external_exif;
PropertiesTable *properties;
@@ -96,13 +92,6 @@ typedef struct {
} TPathInfo;
typedef enum {
- PROP_QUALITY,
- PROP_WIDTH,
- PROP_HEIGHT,
- PROP_LANDSCAPE_W,
- PROP_LANDSCAPE_H,
- PROP_PORTRAIT_W,
- PROP_PORTRAIT_H,
PROP_BORDER_STYLE,
PROP_THUMB_CROP_HINT,
PROP_METADATA_TZ_SHIFT, /* minutes */
diff --git a/src/setup.c b/src/setup.c
index 37a5382..3d1ff2e 100644
--- a/src/setup.c
+++ b/src/setup.c
@@ -102,7 +102,6 @@ parse_setup_xml (const gchar *filename)
setup->erase_exif_thumbnail = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/erase_embed_thumbnail", "value", FALSE);
setup->strip_xmp = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/strip_xmp", "value", TRUE);
setup->write_supplied_exif = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/write_supplied_exif", "value", FALSE);
- setup->nofullsize = xml_file_get_node_present (xml, "/gallery_setup/images/nofullsize");
setup->autorotate = xml_file_get_node_attribute_boolean_with_default (xml, "/gallery_setup/images/autorotate", "value", TRUE);
/* meta section */
@@ -144,6 +143,18 @@ parse_setup_xml (const gchar *filename)
}
+/* Dummy image size sort func */
+static gint
+image_sizes_compare_func (TImageSize *a, TImageSize *b)
+{
+ int sa, sb;
+
+ sa = a->landscape_width + a->landscape_height + a->portrait_width + a->portrait_height + a->square_size;
+ sb = b->landscape_width + b->landscape_height + b->portrait_width + b->portrait_height + b->square_size;
+
+ return sb - sa;
+}
+
/*
* parse_design_setup_xml: XML parser for design.xml file
*/
@@ -238,6 +249,7 @@ parse_design_setup_xml (const gchar *filename)
image_size->fallback_size = xml_file_get_node_attribute (xml, s, "size");
g_free (s);
}
+ design->image_sizes = g_list_sort (design->image_sizes, (GCompareFunc) image_sizes_compare_func);
/* theme section */
diff --git a/src/setup.h b/src/setup.h
index 4afb6d8..faf02f6 100644
--- a/src/setup.h
+++ b/src/setup.h
@@ -39,7 +39,6 @@ typedef struct TGalleryDesign TGalleryDesign;
typedef struct {
gboolean verbose;
gboolean update_mode;
- gboolean override_nofullsize;
gboolean strip_unused_tags;
gboolean warn_resize;
gchar *setup_xml_path;
@@ -57,7 +56,6 @@ typedef struct {
gboolean erase_exif_thumbnail;
gboolean strip_xmp;
gboolean write_supplied_exif;
- gboolean nofullsize;
gboolean autorotate;
/* meta section */