diff options
Diffstat (limited to 'src/generators.c')
| -rw-r--r-- | src/generators.c | 80 |
1 files changed, 42 insertions, 38 deletions
diff --git a/src/generators.c b/src/generators.c index b83382a..1ecb3c6 100644 --- a/src/generators.c +++ b/src/generators.c @@ -206,23 +206,29 @@ get_image_paths (TGallerySetup *setup, if (page_img_dst) *page_img_dst = NULL; - /* 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))) + if (full_img_src == NULL && image_size == NULL) return; s1 = NULL; - if (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX) - s1 = item->thumbnail; - - if (s1 == NULL && item->image_sizes != NULL) - s1 = g_hash_table_lookup (item->image_sizes, image_size->name); - - /* go through the fallback */ - while (s1 == NULL && image_size->fallback_size != NULL) { - image_size = lookup_image_size_for_name (setup, image_size->fallback_size); - s1 = item->image_sizes ? g_hash_table_lookup (item->image_sizes, image_size->name) : NULL; + /* image_size == NULL means return real image source path */ + if (image_size) { + /* 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 (image_size->is_thumbnail && items->type == GALLERY_TYPE_INDEX) + s1 = item->thumbnail; + + if (s1 == NULL && item->image_sizes != NULL) + s1 = g_hash_table_lookup (item->image_sizes, image_size->name); + + /* go through the fallback */ + while (s1 == NULL && image_size->fallback_size != NULL) { + image_size = lookup_image_size_for_name (setup, image_size->fallback_size); + 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 source image */ @@ -237,19 +243,21 @@ get_image_paths (TGallerySetup *setup, if (full_img_src) *full_img_src = g_build_filename (path_info->src_dir, s1, NULL); - target_image_dir = g_strdup_printf ("%s%s", TARGET_IMAGE_DIR_PREFIX, image_size->name); - s2 = g_path_get_basename (s1); - if (image_size->is_thumbnail) { - s3 = g_strdup_printf (THUMBNAIL_NAME_FORMAT, get_item_index (items, item), s2); + if (image_size) { + target_image_dir = g_strdup_printf ("%s%s", TARGET_IMAGE_DIR_PREFIX, image_size->name); + s2 = g_path_get_basename (s1); + if (image_size->is_thumbnail) { + s3 = g_strdup_printf (THUMBNAIL_NAME_FORMAT, get_item_index (items, item), s2); + g_free (s2); + s2 = s3; + } + if (full_img_dst) + *full_img_dst = g_build_filename (path_info->dest_dir, target_image_dir, s2, NULL); + if (page_img_dst) + *page_img_dst = g_build_filename (target_image_dir, s2, NULL); g_free (s2); - s2 = s3; + g_free (target_image_dir); } - if (full_img_dst) - *full_img_dst = g_build_filename (path_info->dest_dir, target_image_dir, s2, NULL); - if (page_img_dst) - *page_img_dst = g_build_filename (target_image_dir, s2, NULL); - g_free (s2); - g_free (target_image_dir); } @@ -711,7 +719,6 @@ get_img_exif_data (TGallerySetup *setup, TImageSize *image_size) { ExifData *exif; - TImageSize *orig_image_size; gchar *img_orig_src; gchar *img_dst; gchar *s; @@ -726,20 +733,17 @@ get_img_exif_data (TGallerySetup *setup, g_free (s); } - /* Get EXIF data from the original image */ + /* Get EXIF data from the source image */ if (exif == NULL) { img_orig_src = NULL; - orig_image_size = lookup_image_size_for_name (setup, "original"); - if (orig_image_size) { - get_image_paths (setup, items, item, path_info, orig_image_size, &img_orig_src, NULL, NULL); - if (img_orig_src != NULL && g_access (img_orig_src, R_OK) == 0) - exif = read_exif (img_orig_src); - /* -- silently succeed - if (exif == NULL) - log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_orig_src); - */ - g_free (img_orig_src); - } + get_image_paths (setup, items, item, path_info, NULL, &img_orig_src, NULL, NULL); + if (img_orig_src != NULL && g_access (img_orig_src, R_OK) == 0) + exif = read_exif (img_orig_src); + /* -- silently succeed + if (exif == NULL) + log_error ("write_html_image: error getting exif data from file \"%s\"\n", img_orig_src); + */ + g_free (img_orig_src); } /* Try destination image size instead, though it might have the metadata stripped */ |
