From 6a16a08ea3e75a524cb136f4c6ada1e4eef4bfd4 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 11 Sep 2016 14:03:13 +0200 Subject: generators: Optionally warn when an image is being resized This adds commandline argument --debug-warn-resize that is useful for debugging image resizing, particularly for detecting unintended supplied image resizes. --- src/cgg.c | 3 +++ src/generators.c | 11 ++++++++--- src/setup.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/cgg.c b/src/cgg.c index e13ffbb..146c687 100644 --- a/src/cgg.c +++ b/src/cgg.c @@ -44,6 +44,7 @@ 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; @@ -69,6 +70,7 @@ parse_cmd (int argc, char *argv[]) { "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,6 +219,7 @@ main (int argc, char* argv[]) setup->update_mode = update; setup->override_nofullsize = fullsize; setup->strip_unused_tags = ! dont_strip_unused_tags; + setup->warn_resize = warn_resize; path_info = g_malloc0 (sizeof (TPathInfo)); path_info->templates_root = templates_basedir; diff --git a/src/generators.c b/src/generators.c index e08f0f5..7fad313 100644 --- a/src/generators.c +++ b/src/generators.c @@ -431,6 +431,7 @@ generate_image (TGallerySetup *setup, 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; @@ -475,8 +476,8 @@ generate_image (TGallerySetup *setup, } /* Resize image */ else { - get_image_sizes (img_src, &img_w, &img_h, setup->autorotate); - if (img_w > 0 && img_h > 0) { + get_image_sizes (img_src, &src_img_w, &src_img_h, setup->autorotate); + if (src_img_w > 0 && src_img_h > 0) { stats_images_inc (); if (image_size->is_thumbnail && image_size->thumb_crop_style != CROP_STYLE_NORMAL) { @@ -493,6 +494,8 @@ 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); @@ -524,10 +527,12 @@ generate_image (TGallerySetup *setup, 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)) log_error (" Error resizing image %s\n", img_src); } else { - log_error ("generate_image: image %s sizes are %lux%lu\n", img_src, img_w, img_h); + log_error ("generate_image: image %s sizes are %lux%lu\n", img_src, src_img_w, src_img_h); } } } diff --git a/src/setup.h b/src/setup.h index bf8f9a7..4afb6d8 100644 --- a/src/setup.h +++ b/src/setup.h @@ -41,6 +41,7 @@ typedef struct { gboolean update_mode; gboolean override_nofullsize; gboolean strip_unused_tags; + gboolean warn_resize; gchar *setup_xml_path; gint version; -- cgit v1.2.3