From 9c2c964727e4a484acf7f97267a3cf1c8fbacd89 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sat, 11 Apr 2009 15:43:15 +0200 Subject: Print statistics in verbose mode --- src/generators.c | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) (limited to 'src/generators.c') diff --git a/src/generators.c b/src/generators.c index 8100196..8dd6a58 100644 --- a/src/generators.c +++ b/src/generators.c @@ -32,6 +32,7 @@ #include "gallery-utils.h" #include "replace-table.h" #include "block-parser.h" +#include "stats.h" /* @@ -86,6 +87,7 @@ generate_image (TGallerySetup *setup, get_image_sizes (img_src_full, &new_w, &new_h); if ((new_w > 0) && (new_h > 0)) { + stats_images_inc (); item->gen_portrait = (new_w / new_h) < 1; /* Generate thumbnail */ @@ -99,11 +101,11 @@ generate_image (TGallerySetup *setup, else calculate_sizes (setup->thumbnail_portrait_width, setup->thumbnail_portrait_height, &thumb_w, &thumb_h); if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE)) - fprintf (stderr, "generate_image: error resizing thumbnail %s\n", thumb_src_full); + log_error ("generate_image: error resizing thumbnail %s\n", thumb_src_full); else g_free (thumb_dst); } else - fprintf (stderr, "generate_image: thumbnail %s sizes are %lux%lu\n", thumb_src_full, thumb_w, thumb_h); + log_error ("generate_image: thumbnail %s sizes are %lux%lu\n", thumb_src_full, thumb_w, thumb_h); /* Generate/copy preview and original image */ @@ -139,14 +141,14 @@ generate_image (TGallerySetup *setup, g_assert (img_src_full != NULL); if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq, FALSE)) - fprintf (stderr, "generate_image: error resizing big image %s\n", img_src_full); + log_error ("generate_image: error resizing big image %s\n", img_src_full); } else { /* Copy the preview (big) image provided */ big_src = g_strconcat (items->base_dir, "/", item->preview, NULL); if (! copy_file (big_src, big_dst)) - fprintf (stderr, "generate_image: error copying preview image %s\n", big_src); + log_error ("generate_image: error copying preview image %s\n", big_src); g_free (big_src); } modify_exif (big_dst, setup->erase_exif_thumbnail, setup->add_copyright); @@ -157,7 +159,7 @@ generate_image (TGallerySetup *setup, { orig_dst = g_strconcat (dst_dir, "/", setup->img_orig_dir, "/", item->gen_img_src, NULL); if (! copy_file(img_src_full, orig_dst)) - fprintf (stderr, "generate_image: error copying original image %s\n", img_src_full); + log_error ("generate_image: error copying original image %s\n", img_src_full); modify_exif (orig_dst, setup->erase_exif_thumbnail, setup->add_copyright); g_free (orig_dst); } @@ -202,12 +204,12 @@ write_html_album (TGallerySetup *setup, fin = fopen (template_src, "r"); if (fin == NULL) { - fprintf (stderr, "write_html_index: error reading file \"%s\": %s\n", template_src, strerror (errno)); + log_error ("write_html_index: error reading file \"%s\": %s\n", template_src, strerror (errno)); return FALSE; } fout = fopen (dst, "w"); if (fout == NULL) { - fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); fclose (fin); return FALSE; } @@ -357,7 +359,7 @@ write_html_album (TGallerySetup *setup, { item = g_ptr_array_index (items->items, i); if (item == NULL) { - fprintf (stderr, "write_html_index: error getting item %d\n", i); + log_error ("write_html_index: error getting item %d\n", i); continue; } @@ -413,7 +415,7 @@ write_html_album (TGallerySetup *setup, bb = fputs (line, fout); g_free (line); if (! bb) { - fprintf (stderr, "write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_index: error writing to file \"%s\": %s\n", dst, strerror (errno)); res = FALSE; break; } @@ -472,12 +474,12 @@ write_html_image (TGallerySetup *setup, fin = fopen (template_src, "r"); if (fin == NULL) { - fprintf (stderr, "write_html_image: error reading file \"%s\": %s\n", template_src, strerror (errno)); + log_error ("write_html_image: error reading file \"%s\": %s\n", template_src, strerror (errno)); return FALSE; } fout = fopen (dst, "w"); if (fout == NULL) { - fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); fclose (fin); return FALSE; } @@ -528,7 +530,7 @@ write_html_image (TGallerySetup *setup, /* Get EXIF data from the original image */ if (get_exif (original_img, &exif)) - fprintf (stderr, "write_html_image: error getting exif data from file \"%s\"\n", orig_dst); + log_error ("write_html_image: error getting exif data from file \"%s\"\n", orig_dst); /* Retrieve image sizes of preview and original image */ get_image_sizes (big_dst, &img_big_w, &img_big_h); @@ -746,7 +748,7 @@ write_html_image (TGallerySetup *setup, bb = fputs (line, fout); g_free (line); if (! bb) { - fprintf (stderr, "write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); + log_error ("write_html_image: error writing to file \"%s\": %s\n", dst, strerror (errno)); res = FALSE; break; } -- cgit v1.2.3