diff options
Diffstat (limited to 'src/generators.c')
| -rw-r--r-- | src/generators.c | 107 |
1 files changed, 21 insertions, 86 deletions
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); |
