summaryrefslogtreecommitdiff
path: root/src/generators.c
diff options
context:
space:
mode:
authorTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 19:08:22 +0100
committerTomas Bzatek <tbzatek@users.sourceforge.net>2011-01-23 19:08:22 +0100
commit45b9708729828f944c07f8b99e7001490261cc53 (patch)
tree1e0ac9d90d53e3b8db7a9650e63e1381a1c17ee7 /src/generators.c
parentede4432dab952314a57c94d8e713814e651f83ca (diff)
downloadcataract-45b9708729828f944c07f8b99e7001490261cc53.tar.xz
Get thumbnail orientation when really needed
No need to store generated data during thread work anymore.
Diffstat (limited to 'src/generators.c')
-rw-r--r--src/generators.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/src/generators.c b/src/generators.c
index a8bdc36..c9fc4ef 100644
--- a/src/generators.c
+++ b/src/generators.c
@@ -109,8 +109,7 @@ generate_image (TGallerySetup *setup,
TIndexItem *item,
unsigned int item_index,
TPathInfo *path_info,
- gboolean update_when_necessary,
- gboolean *thumb_portrait)
+ gboolean update_when_necessary)
{
unsigned long new_w, new_h;
unsigned long thumb_w, thumb_h;
@@ -163,12 +162,11 @@ generate_image (TGallerySetup *setup,
if (new_w > 0 && new_h > 0) {
stats_images_inc ();
- source_img_portrait = (new_w / new_h) < 1;
+ source_img_portrait = new_h > new_w;
/* Generate thumbnail */
g_assert (thumb_src_full != NULL);
get_image_sizes (thumb_src_full, &thumb_w, &thumb_h);
- *thumb_portrait = (thumb_w / thumb_h) < 1;
if (thumb_w > 0 && thumb_h > 0) {
/* Squared thumbnails */
@@ -177,10 +175,10 @@ generate_image (TGallerySetup *setup,
thumb_h = setup->thumbnail_square_size;
} else
/* Portrait / Landscape thumbnails */
- if (! *thumb_portrait)
- calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &thumb_w, &thumb_h);
- else
+ if (thumb_h > thumb_w)
calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &thumb_w, &thumb_h);
+ else
+ calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &thumb_w, &thumb_h);
if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE, setup->squared_thumbnail_type))
log_error ("generate_image: error resizing thumbnail %s\n", thumb_src_full);
} else {
@@ -462,26 +460,31 @@ write_html_album (TGallerySetup *setup,
case INDEX_ITEM_TYPE_PICTURE:
/* Skip HTML code generation if it's a hidden item */
if (! item->hidden) {
+ s2 = item_get_thumbnail_src (setup, items, item, i);
+ if (s2 != NULL) {
+ s4 = g_build_filename (path_info->dest_dir, setup->thumbnail_dir, s2, NULL);
+ get_image_sizes (s4, &img_thumb_w, &img_thumb_h);
+ g_free (s4);
+ s1 = (img_thumb_h > img_thumb_w) ? "IMG_LIST_PORTRAIT" : "IMG_LIST_LANDSCAPE";
+ }
+
if (setup->squared_thumbnail_type != THUMBNAIL_SQUARE_TYPE_NONE)
s1 = "IMG_LIST_SQUARED";
- else
- s1 = item->gen_portrait ? "IMG_LIST_PORTRAIT" : "IMG_LIST_LANDSCAPE";
+ if (! s1)
+ s1 = "IMG_LIST_LANDSCAPE"; /* fallback case */
+
s1 = block_parser_get_data (block_parser, s1);
+ if (s2 != NULL) {
+ replace_table_add_key_printf (local_replace_table, "IMG_THUMBNAIL", "%s/%s", setup->thumbnail_dir, s2);
+ replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_W", img_thumb_w);
+ replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_H", img_thumb_h);
+ }
+ g_free (s2);
replace_table_add_key_printf (local_replace_table, "ALBUM_SUBPATH", "%s/%s", item->path, setup->index_file_name);
s3 = item_get_img_src (setup, items, item);
replace_table_add_key_printf (local_replace_table, "IMG_SUBPAGE", "%s%s", s3, GET_EXT (setup->index_file_name));
replace_table_add_key (local_replace_table, "IMG_FILENAME", s3);
g_free (s3);
- s3 = item_get_thumbnail_src (setup, items, item, i);
- if (s3 != NULL) {
- replace_table_add_key_printf (local_replace_table, "IMG_THUMBNAIL", "%s/%s", setup->thumbnail_dir, s3);
- s4 = g_build_filename (path_info->dest_dir, setup->thumbnail_dir, s3, NULL);
- get_image_sizes (s4, &img_thumb_w, &img_thumb_h);
- g_free (s4);
- replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_W", img_thumb_w);
- replace_table_add_key_int (local_replace_table, "IMG_SIZE_THUMB_H", img_thumb_h);
- }
- g_free (s3);
replace_table_add_key (local_replace_table, "IMG_TITLE", item->title);
replace_table_add_key (local_replace_table, "IMG_DESCRIPTION", item->title_description);
replace_table_add_key_printf (local_replace_table, "IMG_LIST_ID", "i%d", i + 1);