diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2014-09-15 23:45:14 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2014-09-15 23:45:14 +0200 |
| commit | d8708c220afc84549e5e4feaa09f32aa46aba4b5 (patch) | |
| tree | 5c5f3a2aca7de56737a739e667c5f428321d3c34 /src/jpeg-utils.cpp | |
| parent | 2ab38412b14f38202b364558031ddb7db357f1ec (diff) | |
| download | cataract-d8708c220afc84549e5e4feaa09f32aa46aba4b5.tar.xz | |
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 <squared_thumbnails> tag from setup.xml
file but retains fallback for ver. 1 setup.xml files.
Diffstat (limited to 'src/jpeg-utils.cpp')
| -rw-r--r-- | src/jpeg-utils.cpp | 50 |
1 files changed, 23 insertions, 27 deletions
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 */ |
