From d982fa6f55588ada8e5dd1bcb680ac817fcc5de4 Mon Sep 17 00:00:00 2001 From: Tomas Bzatek Date: Tue, 4 Oct 2016 21:54:28 +0200 Subject: 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 ( section) with the following syntax: --- src/jpeg-utils.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/jpeg-utils.cpp') 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) { -- cgit v1.2.3