diff options
| author | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2016-10-04 21:54:28 +0200 |
|---|---|---|
| committer | Tomas Bzatek <tbzatek@users.sourceforge.net> | 2016-10-04 21:54:28 +0200 |
| commit | d982fa6f55588ada8e5dd1bcb680ac817fcc5de4 (patch) | |
| tree | 0de45bd9219c49ccd77d4cb6cdae0d55a78a582b /src/jpeg-utils.cpp | |
| parent | ddd9556689af055355a07cf2766fe95eaed4e38e (diff) | |
| download | cataract-d982fa6f55588ada8e5dd1bcb680ac817fcc5de4.tar.xz | |
items: Add option to shave image borders
A workaround for badly exported images that contain some garbage
at the borders. The amount specifies how many pixels should be shaved
from all borders (i.e. amount of 2 results in 4x4 pixels loss).
Applicable for particular items or whole album (<general> section)
with the following syntax:
<shave amount="1" />
Diffstat (limited to 'src/jpeg-utils.cpp')
| -rw-r--r-- | src/jpeg-utils.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/jpeg-utils.cpp b/src/jpeg-utils.cpp index d7134c2..e9e1e65 100644 --- a/src/jpeg-utils.cpp +++ b/src/jpeg-utils.cpp @@ -540,8 +540,12 @@ resize_image (const gchar *src, const gchar *dst, autorotate_image (magick_wand); /* Don't resize if smaller than desired size */ - if (hidpi_strict_dimensions || MagickGetImageWidth (magick_wand) > size_x || MagickGetImageHeight (magick_wand) > size_y) + if (hidpi_strict_dimensions || MagickGetImageWidth (magick_wand) > size_x || MagickGetImageHeight (magick_wand) > size_y || exif->shave_amount > 0) { + /* Shave borders if requested */ + if (exif->shave_amount > 0) + MagickShaveImage (magick_wand, exif->shave_amount, exif->shave_amount); + /* Prepare image before resizing */ if (thumbnail) { if (exif->thumbnail_crop_style != CROP_STYLE_NORMAL) { |
