diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 18:11:42 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2013-04-07 18:11:42 +0200 |
| commit | ced9539fef270fe133cb0ad6fc04c30bd5fa2dfe (patch) | |
| tree | 91e432faf1482e7adedcd0ea6e6942861325d7dc /src/jpeg-utils.cpp | |
| parent | d912f084ffbcae0ca4b8fdfb355d6bbd6a6d3506 (diff) | |
| download | cataract-ced9539fef270fe133cb0ad6fc04c30bd5fa2dfe.tar.xz | |
Add ability to specify thumbnail square crop hint
In simple crop square mode it's sometimes viable to specify position
of the square. This is vastly useful for portrait pictures so that you
don't crop the head off the body.
Diffstat (limited to 'src/jpeg-utils.cpp')
| -rw-r--r-- | src/jpeg-utils.cpp | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp index d7382c8..be95ec9 100644 --- a/src/jpeg-utils.cpp +++ b/src/jpeg-utils.cpp @@ -432,8 +432,8 @@ resize_image (const gchar *src, const gchar *dst, unsigned long size_x, unsigned long size_y, int quality, gboolean thumbnail, - ThumbnailSquareType squared_thumbnail_type, - gboolean autorotate) + gboolean autorotate, + ExifData *exif) { MagickWand *magick_wand; ExceptionType severity; @@ -460,13 +460,30 @@ resize_image (const gchar *src, const gchar *dst, { /* Process thumbnail if required */ if (thumbnail) { - switch (squared_thumbnail_type) { + 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); - MagickCropImage (magick_wand, amount, amount, (w - amount) / 2, (h - amount) / 2); + 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; |
