diff options
Diffstat (limited to 'src/generators.c')
| -rw-r--r-- | src/generators.c | 41 |
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); |
