From 248a9af6ad668b6f09f79dda548721756fe11d79 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Sun, 4 Jan 2015 23:01:42 +0100 Subject: Introduce new "fixed" thumbnail crop mode This mode retains given aspect ratio and crops the area from inside of the source image. --- src/generators.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'src/generators.c') diff --git a/src/generators.c b/src/generators.c index 2e8cca6..f627839 100644 --- a/src/generators.c +++ b/src/generators.c @@ -300,7 +300,7 @@ metadata_apply_overrides (ExifData *exif_data, if (setup->write_supplied_exif && item->metadata_external_exif) exif_data->external_exif_data = g_path_is_absolute (item->metadata_external_exif) ? g_strdup (item->metadata_external_exif) : g_build_filename (path_info->src_dir, item->metadata_external_exif, NULL); - exif_data->squared_thumbnail = image_size->is_thumbnail && image_size->squared_thumb; + exif_data->thumbnail_crop_style = image_size->is_thumbnail ? image_size->thumb_crop_style : CROP_STYLE_NORMAL; exif_data->thumbnail_crop_hint = get_prop_int (items, item, PROP_THUMB_CROP_HINT, CROP_HINT_UNDEFINED); } @@ -403,8 +403,19 @@ generate_image (TGallerySetup *setup, if (img_w > 0 && img_h > 0) { stats_images_inc (); - if (image_size->is_thumbnail && image_size->squared_thumb) - img_w = img_h = image_size->square_size; + if (image_size->is_thumbnail && image_size->thumb_crop_style != CROP_STYLE_NORMAL) { + switch (image_size->thumb_crop_style) { + case CROP_STYLE_SQUARED: + img_w = img_h = image_size->square_size; + break; + case CROP_STYLE_FIXED: + img_w = image_size->crop_width; + img_h = image_size->crop_height; + break; + default: + g_assert_not_reached (); + } + } else { /* Only the "preview" size is affected by deprecated item and album overrides */ if (is_preview) { @@ -795,7 +806,7 @@ process_img_item (TGallerySetup *setup, if (s2 != NULL) get_image_sizes (s2, &img_thumb_w, &img_thumb_h, setup->autorotate); - if (thumb_image_size->squared_thumb || img_thumb_w == img_thumb_h) + if (img_thumb_w == img_thumb_h) replace_table_add_key (replace_table, "THUMB_ORIENTATION", "squared"); else replace_table_add_key (replace_table, "THUMB_ORIENTATION", (img_thumb_h > img_thumb_w) ? "portrait" : "landscape"); -- cgit v1.2.3