From d8708c220afc84549e5e4feaa09f32aa46aba4b5 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Mon, 15 Sep 2014 23:45:14 +0200 Subject: theming: Allow themes to use different thumbnail image sizes This change makes thumbnail image sizes more flexible by explicitly stating the particular image size is a thumbnail. And each thumbnail image size can have different squared settings. On the theme side it's now mandatory to specify which thumbnail size to use (if applicable). This allows us to have different thumbnail styles for index and album pages. This commit also removes the tag from setup.xml file but retains fallback for ver. 1 setup.xml files. --- src/jpeg-utils.cpp | 50 +++++++++++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 27 deletions(-) (limited to 'src/jpeg-utils.cpp') diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp index 5c0269a..a552e69 100644 --- a/src/jpeg-utils.cpp +++ b/src/jpeg-utils.cpp @@ -481,33 +481,29 @@ resize_image (const gchar *src, const gchar *dst, { /* Process thumbnail if required */ if (thumbnail) { - switch (exif->squared_thumbnail_type) { - case THUMBNAIL_SQUARE_TYPE_SIMPLE: - w = MagickGetImageWidth (magick_wand); - h = MagickGetImageHeight (magick_wand); - amount = MAX (w, h) * SQUARED_SIMPLE_SHAVE_AMOUNT / 100; - amount = MIN (w - 2*amount, h - 2*amount); - switch (exif->thumbnail_crop_hint) { - case CROP_HINT_UNDEFINED: - case CROP_HINT_CENTER: - MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, (h - amount) / 2); - break; - case CROP_HINT_LEFT: - MagickCropImage (magick_wand, amount, amount, 0, (h - amount) / 2); - break; - case CROP_HINT_RIGHT: - MagickCropImage (magick_wand, amount, amount, w - amount, (h - amount) / 2); - break; - case CROP_HINT_TOP: - MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, 0); - break; - case CROP_HINT_BOTTOM: - MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, h - amount); - break; - } - break; - default: - break; + if (exif->squared_thumbnail) { + w = MagickGetImageWidth (magick_wand); + h = MagickGetImageHeight (magick_wand); + amount = MAX (w, h) * SQUARED_SIMPLE_SHAVE_AMOUNT / 100; + amount = MIN (w - 2*amount, h - 2*amount); + switch (exif->thumbnail_crop_hint) { + case CROP_HINT_UNDEFINED: + case CROP_HINT_CENTER: + MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, (h - amount) / 2); + break; + case CROP_HINT_LEFT: + MagickCropImage (magick_wand, amount, amount, 0, (h - amount) / 2); + break; + case CROP_HINT_RIGHT: + MagickCropImage (magick_wand, amount, amount, w - amount, (h - amount) / 2); + break; + case CROP_HINT_TOP: + MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, 0); + break; + case CROP_HINT_BOTTOM: + MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, h - amount); + break; + } } MagickThumbnailImage (magick_wand, size_x, size_y); /* FIXME: this strips image ICC profile, should do proper conversion first */ -- cgit v1.2.3