From 7c07cbdbc469d8eab075d32c27039d8683b9cdf8 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 30 Dec 2008 20:38:35 +0100 Subject: Strip unneeded blocks during thumbnail generation --- generators.c | 4 ++-- jpeg-utils.cpp | 8 ++++++-- jpeg-utils.h | 4 +++- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/generators.c b/generators.c index 8c8bc4e..b94a691 100644 --- a/generators.c +++ b/generators.c @@ -101,7 +101,7 @@ generate_image (TGallerySetup *setup, calculate_sizes (setup->thumbnail_landscape_width, setup->thumbnail_landscape_height, &thumb_w, &thumb_h); 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)) + if (! resize_image (thumb_src_full, thumb_dst, thumb_w, thumb_h, setup->thumbnail_quality, TRUE)) fprintf (stderr, "write_html_index: error resizing thumbnail %s\n", thumb_src_full); else if (setup->verbose) printf (" done.\n"); @@ -147,7 +147,7 @@ generate_image (TGallerySetup *setup, } } - if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq)) + if (! resize_image (img_src_full, big_dst, new_w, new_h, bigq, FALSE)) fprintf (stderr, "write_html_index: error resizing big image %s\n", img_src_full); else if (setup->verbose) printf (" done.\n"); diff --git a/jpeg-utils.cpp b/jpeg-utils.cpp index cb8238a..b550b21 100644 --- a/jpeg-utils.cpp +++ b/jpeg-utils.cpp @@ -286,7 +286,8 @@ free_exif_data (TExifData *data) gboolean resize_image (const char *src, const char *dst, int size_x, int size_y, - int quality) + int quality, + gboolean thumbnail) { #define ThrowWandException(wand) \ { \ @@ -308,7 +309,10 @@ resize_image (const char *src, const char *dst, status = MagickReadImage (magick_wand, src); if (status == MagickFalse) ThrowWandException (magick_wand); - MagickResizeImage (magick_wand, size_x, size_y, LanczosFilter, 1.0); + if (thumbnail) + MagickThumbnailImage (magick_wand, size_x, size_y); + else + MagickResizeImage (magick_wand, size_x, size_y, LanczosFilter, 1.0); MagickSetImageCompressionQuality (magick_wand, quality); /* Write the image and destroy it. */ diff --git a/jpeg-utils.h b/jpeg-utils.h index e5e39de..aec1a96 100644 --- a/jpeg-utils.h +++ b/jpeg-utils.h @@ -63,10 +63,12 @@ void free_exif_data (TExifData *data); /* * resize_image: resize image pointed by src and save result to dst + * - setting thumbnail flag will remove all profiles and optimize for size */ gboolean resize_image (const char *src, const char *dst, int size_x, int size_y, - int quality); + int quality, + gboolean thumbnail); /* * get_image_sizes: retrieve image dimensions -- cgit v1.2.3